[rubygems/rubygems] Emit progress to stderr when --parseable
is passed to bundle outdated
Before, `bundle outdated --parseable` (or `--porcelain`) caused output to be completely silenced during definition resolution, so nothing was printed at all until the table of outdated gems was printed. With this change, `--parseable`/`--porcelain` now prints progress to stderr during resolution. E.g.: ``` Fetching gem metadata from https://rubygems.org/......... Resolving dependencies... ``` This provides a better user experience, especially when `outdated --parseable` takes several seconds or more. The report of outdated gems is still printed to stdout, and the exit status codes are unchanged, so the fundamental contract with other tools consuming the `outdated --parseable` result should not be affected. https://github.com/rubygems/rubygems/commit/7d4bb43570
This commit is contained in:
parent
08b92b67ff
commit
830ff66e2c
@ -54,7 +54,7 @@ module Bundler
|
||||
end
|
||||
|
||||
if options[:parseable]
|
||||
Bundler.ui.silence(&definition_resolution)
|
||||
Bundler.ui.progress(&definition_resolution)
|
||||
else
|
||||
definition_resolution.call
|
||||
end
|
||||
|
@ -119,6 +119,10 @@ module Bundler
|
||||
with_level("silent", &blk)
|
||||
end
|
||||
|
||||
def progress(&blk)
|
||||
with_output_stream(:stderr, &blk)
|
||||
end
|
||||
|
||||
def unprinted_warnings
|
||||
[]
|
||||
end
|
||||
@ -170,6 +174,14 @@ module Bundler
|
||||
ensure
|
||||
@level = original
|
||||
end
|
||||
|
||||
def with_output_stream(symbol)
|
||||
original = output_stream
|
||||
self.output_stream = symbol
|
||||
yield
|
||||
ensure
|
||||
@output_stream = original
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -84,6 +84,10 @@ module Bundler
|
||||
yield
|
||||
end
|
||||
|
||||
def progress
|
||||
yield
|
||||
end
|
||||
|
||||
def unprinted_warnings
|
||||
@warnings
|
||||
end
|
||||
|
@ -438,19 +438,40 @@ RSpec.describe "bundle outdated" do
|
||||
G
|
||||
end
|
||||
|
||||
it "outputs a sorted list of outdated gems with a more minimal format" do
|
||||
it "outputs a sorted list of outdated gems with a more minimal format to stdout" do
|
||||
minimal_output = "activesupport (newest 3.0, installed 2.3.5, requested = 2.3.5)\n" \
|
||||
"weakling (newest 0.2, installed 0.0.3, requested ~> 0.0.1)"
|
||||
subject
|
||||
expect(out).to eq(minimal_output)
|
||||
end
|
||||
|
||||
it "outputs progress to stderr" do
|
||||
subject
|
||||
expect(err).to include("Fetching gem metadata")
|
||||
end
|
||||
end
|
||||
|
||||
context "and no gems are outdated" do
|
||||
it "has empty output" do
|
||||
before do
|
||||
build_repo2 do
|
||||
build_gem "activesupport", "3.0"
|
||||
end
|
||||
|
||||
install_gemfile <<-G
|
||||
source "https://gem.repo2"
|
||||
gem "activesupport", "3.0"
|
||||
G
|
||||
end
|
||||
|
||||
it "does not output to stdout" do
|
||||
subject
|
||||
expect(out).to be_empty
|
||||
end
|
||||
|
||||
it "outputs progress to stderr" do
|
||||
subject
|
||||
expect(err).to include("Fetching gem metadata")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user