aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Contributions
diff options
context:
space:
mode:
authorJack Nagel2013-05-16 14:36:50 -0500
committerJack Nagel2013-05-16 14:57:29 -0500
commite8997c8a5ad1d146fdca26c736393e3bbfe7faf4 (patch)
tree97f5d9f99c4a08e5f293eb576a080a45c70239d9 /Library/Contributions
parent2d8496129c9ae4fcc8a85fd487342fe37ebac107 (diff)
downloadbrew-e8997c8a5ad1d146fdca26c736393e3bbfe7faf4.tar.bz2
linkapps: deal only with kegs, not formulae
Fixes Homebrew/homebrew#19873.
Diffstat (limited to 'Library/Contributions')
-rwxr-xr-xLibrary/Contributions/cmd/brew-linkapps.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/Library/Contributions/cmd/brew-linkapps.rb b/Library/Contributions/cmd/brew-linkapps.rb
index daa19583d..cf394b479 100755
--- a/Library/Contributions/cmd/brew-linkapps.rb
+++ b/Library/Contributions/cmd/brew-linkapps.rb
@@ -1,5 +1,5 @@
# Links any Applications (.app) found in installed prefixes to ~/Applications
-require "formula"
+require 'keg'
TARGET_DIR = ARGV.include?("--system") ? "/Applications" : File.expand_path("~/Applications")
@@ -9,24 +9,24 @@ unless File.exist? TARGET_DIR
exit 1
end
-HOMEBREW_CELLAR.subdirs.each do |keg|
- next unless keg.subdirs
- name = keg.basename.to_s
+HOMEBREW_CELLAR.subdirs.each do |rack|
+ kegs = rack.subdirs.map { |d| Keg.new(d) }
+ next if kegs.empty?
- if ((f = Formula.factory(name)).installed? rescue false)
- Dir["#{f.installed_prefix}/*.app", "#{f.installed_prefix}/bin/*.app", "#{f.installed_prefix}/libexec/*.app"].each do |p|
- puts "Linking #{p}"
- appname = File.basename(p)
- target = TARGET_DIR+"/"+appname
- if File.exist? target
- if File.symlink? target
- system "rm", target
- else
- onoe "#{target} already exists, skipping."
- end
- end
- system "ln", "-s", p, TARGET_DIR
+ keg = kegs.detect(&:linked?) || kegs.max_by(&:version)
+
+ Dir["#{keg}/*.app", "#{keg}/bin/*.app", "#{keg}/libexec/*.app"].each do |app|
+ puts "Linking #{app}"
+ app_name = File.basename(app)
+ target = "#{TARGET_DIR}/#{app_name}"
+
+ if File.exist?(target) && File.symlink?(target)
+ system "rm", target
+ elsif File.exist?(target)
+ onoe "#{target} already exists, skipping."
+ next
end
+ system "ln", "-s", app, TARGET_DIR
end
end