diff options
| author | Vlad Shablinsky | 2016-07-12 10:03:32 +0300 |
|---|---|---|
| committer | Xu Cheng | 2016-08-06 21:25:56 +0800 |
| commit | 09d21ad2586427b91734943a22e286255923bbcf (patch) | |
| tree | f5a5d955c2c508d135c260578b912cf763db5629 /Library | |
| parent | 1693ddbdcbaa9f92355e46af2b28ae5d05afb516 (diff) | |
| download | brew-09d21ad2586427b91734943a22e286255923bbcf.tar.bz2 | |
download_strategy: allow to suppress output
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/download_strategy.rb | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index 0c38e8a46..4d9e80f38 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 |
