diff options
| -rw-r--r-- | lib/leap_cli/util.rb | 19 | 
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/leap_cli/util.rb b/lib/leap_cli/util.rb index d12c5a6..fb5eb52 100644 --- a/lib/leap_cli/util.rb +++ b/lib/leap_cli/util.rb @@ -1,6 +1,7 @@  require 'digest/md5'  require 'paint'  require 'fileutils' +require 'pathname'  require 'erb'  require 'pty' @@ -277,6 +278,24 @@ module LeapCli      end      # +    # creates a relative symlink from absolute paths, removing prior symlink if necessary +    # +    # symlink 'new' is created, pointing to 'old' +    # +    def relative_symlink(old, new) +      relative_path  = Pathname.new(old).relative_path_from(Pathname.new(new)) +      if File.symlink?(new) +        if File.readlink(new) != relative_path.to_s +          File.unlink(new) +          log :updated, 'symlink %s' % Path.relative_path(new) +        end +      else +        log :created, 'symlink %s' % Path.relative_path(new) +      end +      FileUtils.ln_s(relative_path, new) +    end + +    #      # compares md5 fingerprints to see if the contents of a file match the string we have in memory      #      def file_content_equals?(filepath, contents)  | 
