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}"
|
opoo "Already linked: #{keg}"
|
||||||
puts "To relink: brew unlink #{keg.fname} && brew link #{keg.fname}"
|
puts "To relink: brew unlink #{keg.fname} && brew link #{keg.fname}"
|
||||||
next
|
next
|
||||||
end
|
elsif keg_only?(keg.fname) && !ARGV.force?
|
||||||
|
opoo "#{keg.fname} is keg-only and must be linked with --force"
|
||||||
if mode.dry_run and mode.overwrite
|
puts "Note that doing so can interfere with building software."
|
||||||
|
next
|
||||||
|
elsif mode.dry_run && mode.overwrite
|
||||||
print "Would remove:\n" do
|
print "Would remove:\n" do
|
||||||
keg.link(mode)
|
keg.link(mode)
|
||||||
end
|
end
|
||||||
@ -35,16 +37,6 @@ module Homebrew extend self
|
|||||||
next
|
next
|
||||||
end
|
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
|
keg.lock do
|
||||||
print "Linking #{keg}... " do
|
print "Linking #{keg}... " do
|
||||||
puts "#{keg.link(mode)} symlinks created"
|
puts "#{keg.link(mode)} symlinks created"
|
||||||
@ -55,6 +47,12 @@ module Homebrew extend self
|
|||||||
|
|
||||||
private
|
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,
|
# 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.
|
# an exception is thrown, its output starts on a new line.
|
||||||
def print str, &block
|
def print str, &block
|
||||||
|
Loading…
x
Reference in New Issue
Block a user