Fix conflict resolution when destination is a plain file (not a symlink).

This commit is contained in:
Joshua Nichols
2010-03-31 23:18:38 -04:00
parent 5db3048e71
commit cde7989e85
2 changed files with 7 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
require 'pathname'
lib = Pathname.new(__FILE__).dirname.join('..', 'lib').expand_path
$LOAD_PATH.unshift.unshift lib.to_s unless $LOAD_PATH.include?(lib.to_s)
$LOAD_PATH.unshift lib.to_s
require 'homesick'

View File

@@ -31,6 +31,12 @@ class Homesick
system "ln -sf #{source} #{destination}" unless options[:pretend]
end
end
elsif destination.exist?
say_status :conflict, "#{destination} exists", :red unless options[:quiet]
if shell.file_collision(destination) { source }
system "ln -sf #{source} #{destination}" unless options[:pretend]
end
else
say_status :symlink, "#{source.expand_path} to #{destination.expand_path}", :green unless options[:quiet]
system "ln -s #{source} #{destination}" unless options[:pretend]