Permalink
Browse files

Fix conflict resolution when destination is a plain file (not a symli…

…nk).
  • Loading branch information...
1 parent 5db3048 commit cde7989e85963eafa2d9ad1138c019272357b16d @technicalpickles committed Apr 1, 2010
Showing with 7 additions and 1 deletion.
  1. +1 −1 bin/homesick
  2. +6 −0 lib/homesick/actions.rb
View
@@ -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'
@@ -31,6 +31,12 @@ def symlink(source, destination, config = {})
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]

0 comments on commit cde7989

Please sign in to comment.