summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/ext/builder.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/lib/rubygems/ext/builder.rb b/lib/rubygems/ext/builder.rb
index 93be458cd8..54eeae57b6 100644
--- a/lib/rubygems/ext/builder.rb
+++ b/lib/rubygems/ext/builder.rb
@@ -67,12 +67,18 @@ class Gem::Ext::Builder
rubygems_gemdeps, ENV['RUBYGEMS_GEMDEPS'] = ENV['RUBYGEMS_GEMDEPS'], nil
if verbose
puts("current directory: #{Dir.pwd}")
- puts(command)
- system(command)
- else
- results << "current directory: #{Dir.pwd}"
- results << (command.respond_to?(:shelljoin) ? command.shelljoin : command)
- results << IO.popen(command, "r", err: [:child, :out], &:read)
+ p(command)
+ end
+ results << "current directory: #{Dir.pwd}"
+ results << (command.respond_to?(:shelljoin) ? command.shelljoin : command)
+
+ redirections = verbose ? {} : {err: [:child, :out]}
+ IO.popen(command, "r", redirections) do |io|
+ if verbose
+ IO.copy_stream(io, $stdout)
+ else
+ results << io.read
+ end
end
rescue => error
raise Gem::InstallError, "#{command_name || class_name} failed#{error.message}"