Adjust link command for updated error handling

This commit is contained in:
Jack Nagel 2014-04-21 09:40:24 -05:00
parent 6b5e92ac47
commit 72d83adaf3

View File

@ -32,9 +32,16 @@ module Homebrew extend self
end
keg.lock do
print "Linking #{keg}... " do
puts if ARGV.verbose?
puts "#{keg.link(mode)} symlinks created"
print "Linking #{keg}... "
puts if ARGV.verbose?
begin
n = keg.link(mode)
rescue Keg::LinkError
puts
raise
else
puts "#{n} symlinks created"
end
end
end
@ -47,33 +54,4 @@ module Homebrew extend self
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
Kernel.print str
STDERR.extend Module.new {
def puts(*args)
unless $did_puts
STDOUT.puts
$did_puts = true
end
super
end
}
puts_capture = Class.new do
def self.puts(*args)
$did_puts = true
Kernel.puts(*args)
end
end
puts_capture.instance_eval(&block)
ensure
puts unless $did_puts
end
end