diff options
| author | Jack Nagel | 2013-05-16 14:36:50 -0500 |
|---|---|---|
| committer | Jack Nagel | 2013-05-16 14:57:29 -0500 |
| commit | 61764b477bc30449e27ca0d934a5d7b878b45eaa (patch) | |
| tree | 57ebe1970fbe16fe2d8d4f263d15cd471db91219 /Library/Contributions/cmd | |
| parent | b30c3b6636813ed83efaf94fbc8dfa3854e040e8 (diff) | |
| download | homebrew-61764b477bc30449e27ca0d934a5d7b878b45eaa.tar.bz2 | |
linkapps: deal only with kegs, not formulae
Fixes #19873.
Diffstat (limited to 'Library/Contributions/cmd')
| -rwxr-xr-x | Library/Contributions/cmd/brew-linkapps.rb | 34 |
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 |
