Browse Source

properly recognize existing symlinks in linkapps

turns out a symlink of a directory is both a symlink and a directory, so
you have to test for symlink first if you want to catch it.

this should address #36
phinze 12 years ago
parent
commit
eb04e6784a
  1. 6
      lib/cask.rb

6
lib/cask.rb

@ -129,13 +129,13 @@ class Cask
destination_path.entries.select { |f| f.basename.to_s =~ /.app$/ }.each do |app|
symlink_destination = HOME_APPS.join(app.basename)
symlink_target = destination_path.join(app)
if symlink_destination.directory? || symlink_destination.file?
puts "#{symlink_destination} already exists and is not a symlink, not linking #{self}"
elsif symlink_destination.symlink?
if symlink_destination.symlink?
puts "#{symlink_destination} exists but is symlink; removing and relinking"
puts "#{symlink_destination} -> #{symlink_target}"
symlink_destination.delete
symlink_destination.make_symlink(symlink_target)
elsif symlink_destination.directory? || symlink_destination.file?
puts "#{symlink_destination} already exists and is not a symlink, not linking #{self}"
else
puts "#{symlink_destination} -> #{symlink_target}"
symlink_destination.make_symlink(symlink_target)

Loading…
Cancel
Save