diff --git a/lib/cask/actions.rb b/lib/cask/actions.rb index 50f59bf8646..9d1be821345 100644 --- a/lib/cask/actions.rb +++ b/lib/cask/actions.rb @@ -1,19 +1,17 @@ module Cask::Actions def linkapps - puts "looking in #{destination_path}/**/*.app" - puts "found #{Pathname.glob("#{destination_path}/**/*.app").inspect}" Pathname.glob("#{destination_path}/**/*.app").each do |app| destination = Cask.appdir.join(app.basename) target = destination_path.join(app) if destination.symlink? - puts "#{destination} exists but is symlink; removing and relinking" - puts "#{destination} -> #{target}" + # destination exists but is symlink; removing and relinking + puts "[#{self}] linking #{File.basename(destination)}" destination.delete destination.make_symlink(target) elsif destination.directory? || destination.file? - puts "#{destination} already exists and is not a symlink, not linking #{self}" + puts "[#{self}] NOT linking #{File.basename(destination)} - already exists" else - puts "#{destination} -> #{target}" + puts "[#{self}] linking #{File.basename(destination)}" destination.make_symlink(target) end end diff --git a/lib/cask/cli/linkapps.rb b/lib/cask/cli/linkapps.rb index 4d7f53a55f2..0b7ff9035e0 100644 --- a/lib/cask/cli/linkapps.rb +++ b/lib/cask/cli/linkapps.rb @@ -1,8 +1,8 @@ class Cask::CLI::Linkapps def self.run(*args) - casks_to_link = args.empty? ? Cask.installed : args.map { |arg| Cask.load(arg) } - casks_to_link.each do |cask| - cask.linkapps + casks_to_link = args.empty? ? Cask.installed : args + casks_to_link.each do |cask_name| + Cask.load(cask_name).linkapps end end diff --git a/test/cask/actions_test.rb b/test/cask/actions_test.rb index 466ed1059d5..eb30d36ea7e 100644 --- a/test/cask/actions_test.rb +++ b/test/cask/actions_test.rb @@ -18,7 +18,7 @@ describe Cask::Actions do Cask::Installer.uninstall(@caffeine) end - it "works with an applistion in the root directory" do + it "works with an application in the root directory" do shutup do @caffeine.linkapps end diff --git a/test/cli/linkapps_test.rb b/test/cli/linkapps_test.rb index ea523133604..e8b07e6eb57 100644 --- a/test/cli/linkapps_test.rb +++ b/test/cli/linkapps_test.rb @@ -5,7 +5,6 @@ describe Cask::CLI::Linkapps do mock_cask = mock() mock_cask.expects(:linkapps).twice Cask.expects(:load).with('adium').returns(mock_cask) - Cask.expects(:load).with('google-chrome').returns(mock_cask) Cask::CLI::Linkapps.run('adium', 'google-chrome') end @@ -13,8 +12,9 @@ describe Cask::CLI::Linkapps do it "links all installed casks when no arguments supplied" do mock_cask = mock() mock_cask.expects(:linkapps).times(3) + Cask.expects(:load).times(3).returns(mock_cask) - Cask.expects(:installed).returns([mock_cask, mock_cask, mock_cask]) + Cask.expects(:installed).returns(['mock1', 'mock2', 'mock3']) Cask::CLI::Linkapps.run end