aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils/curl.rb
diff options
context:
space:
mode:
authorMike McQuaid2016-07-12 19:46:29 +0100
committerGitHub2016-07-12 19:46:29 +0100
commit23306ab434afc185e22a0f357a27e8da687620af (patch)
treedcf29ed5354a34f609b1250d6f7c4ea81c5cbf12 /Library/Homebrew/utils/curl.rb
parented1d1e51da6bf464d6e461f5214e49f17b1f1842 (diff)
downloadbrew-23306ab434afc185e22a0f357a27e8da687620af.tar.bz2
github: produce better curl error messages. (#441)
* global: add RUBY_TWO global variable. * test-bot: use RUBY_TWO global variable. * github: produce better curl error messages. If we don't know why curl has failed then ensure that the error messages that it produced are included as part of the user output.
Diffstat (limited to 'Library/Homebrew/utils/curl.rb')
-rw-r--r--Library/Homebrew/utils/curl.rb14
1 files changed, 12 insertions, 2 deletions
diff --git a/Library/Homebrew/utils/curl.rb b/Library/Homebrew/utils/curl.rb
index a1653d46c..db3534542 100644
--- a/Library/Homebrew/utils/curl.rb
+++ b/Library/Homebrew/utils/curl.rb
@@ -1,4 +1,5 @@
require "pathname"
+require "open3"
def curl_args(extra_args=[])
curl = Pathname.new ENV["HOMEBREW_CURL"]
@@ -19,6 +20,15 @@ def curl(*args)
end
def curl_output(*args)
- curl_args = curl_args(args) - ["--fail"]
- Utils.popen_read_text(*curl_args)
+ curl_args = curl_args(args)
+ curl_args -= ["--fail"]
+ if RUBY_TWO
+ curl_args -= ["--silent"]
+ Open3.popen3(*curl_args) do |_, stdout, stderr, wait_thread|
+ [stdout.read, stderr.read, wait_thread.value]
+ end
+ else
+ output = Utils.popen_read_text(*curl_args)
+ [output, nil, $?]
+ end
end