blob: dba9beaa50be5d3409c01fa226e65a39a7559884 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# Links any Applications (.app) found in installed prefixes to /Applications
require "keg"
require "formula"
module Homebrew
def linkapps
target_dir = ARGV.include?("--local") ? File.expand_path("~/Applications") : "/Applications"
unless File.exist? target_dir
opoo "#{target_dir} does not exist, stopping."
puts "Run `mkdir #{target_dir}` first."
exit 1
end
if ARGV.named.empty?
kegs = Formula.racks.map do |rack|
keg = rack.subdirs.map { |d| Keg.new(d) }
next if keg.empty?
keg.detect(&:linked?) || keg.max { |a, b| a.version <=> b.version }
end
else
kegs = ARGV.kegs
end
kegs.each do |keg|
keg.apps.each do |app|
puts "Linking #{app} to #{target_dir}."
target = "#{target_dir}/#{app.basename}"
if File.exist?(target) && !File.symlink?(target)
onoe "#{target} already exists, skipping."
next
end
system "ln", "-sf", app, target_dir
end
end
end
end
|