link: extract keg-only check into a helper method
This commit is contained in:
parent
5d48f46178
commit
92b6bcb77d
@ -19,9 +19,11 @@ module Homebrew extend self
|
||||
opoo "Already linked: #{keg}"
|
||||
puts "To relink: brew unlink #{keg.fname} && brew link #{keg.fname}"
|
||||
next
|
||||
end
|
||||
|
||||
if mode.dry_run and mode.overwrite
|
||||
elsif keg_only?(keg.fname) && !ARGV.force?
|
||||
opoo "#{keg.fname} is keg-only and must be linked with --force"
|
||||
puts "Note that doing so can interfere with building software."
|
||||
next
|
||||
elsif mode.dry_run && mode.overwrite
|
||||
print "Would remove:\n" do
|
||||
keg.link(mode)
|
||||
end
|
||||
@ -35,16 +37,6 @@ module Homebrew extend self
|
||||
next
|
||||
end
|
||||
|
||||
begin
|
||||
f = Formula.factory(keg.fname)
|
||||
if f.keg_only? and not ARGV.force?
|
||||
opoo "#{keg.fname} is keg-only and must be linked with --force"
|
||||
puts "Note that doing so can interfere with building software."
|
||||
next
|
||||
end
|
||||
rescue FormulaUnavailableError
|
||||
end
|
||||
|
||||
keg.lock do
|
||||
print "Linking #{keg}... " do
|
||||
puts "#{keg.link(mode)} symlinks created"
|
||||
@ -55,6 +47,12 @@ module Homebrew extend self
|
||||
|
||||
private
|
||||
|
||||
def keg_only?(name)
|
||||
Formula.factory(name).keg_only?
|
||||
rescue FormulaUnavailableError
|
||||
false
|
||||
end
|
||||
|
||||
# Allows us to ensure a puts happens before the block exits so that if say,
|
||||
# an exception is thrown, its output starts on a new line.
|
||||
def print str, &block
|
||||
|
Loading…
x
Reference in New Issue
Block a user