diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 0c38e8a46e..4d9e80f38d 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -6,6 +6,7 @@ class AbstractDownloadStrategy include FileUtils attr_reader :meta, :name, :version, :resource + attr_reader :shutup def initialize(name, resource) @name = name @@ -19,6 +20,19 @@ class AbstractDownloadStrategy def fetch end + # Supress output + def shutup! + @shutup = true + end + + def puts(*args) + super(*args) unless shutup + end + + def ohai(*args) + super(*args) unless shutup + end + # Unpack {#cached_location} into the current working directory, and possibly # chdir into the newly-unpacked directory. # Unlike {Resource#stage}, this does not take a block. @@ -59,6 +73,14 @@ class AbstractDownloadStrategy args end + def safe_system(*args) + if @shutup + quiet_system(*args) || raise(ErrorDuringExecution.new(args.shift, *args)) + else + super(*args) + end + end + def quiet_safe_system(*args) safe_system(*expand_safe_system_args(args)) end