diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-21 12:36:05 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-06-23 12:43:54 -0500 |
commit | 87370195728549ed989ca8b63bf6bd30b1702819 (patch) | |
tree | 5176b5a012e3e0879e4a485add17ec4b954f9c51 | |
parent | 07573bf07daf52b1232e4bd3cfc178a019f9baff (diff) | |
download | bundler-87370195728549ed989ca8b63bf6bd30b1702819.tar.gz |
[UI::Shell] Warn on STDERR in Bundler 2
-rw-r--r-- | lib/bundler/ui/shell.rb | 5 | ||||
-rw-r--r-- | spec/bundler/ui/shell_spec.rb | 15 |
2 files changed, 17 insertions, 3 deletions
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb index a1a2cbad18..e0d0d68aa9 100644 --- a/lib/bundler/ui/shell.rb +++ b/lib/bundler/ui/shell.rb @@ -30,9 +30,12 @@ module Bundler end def warn(msg, newline = nil) + return unless level("warn") return if @warning_history.include? msg @warning_history << msg - tell_me(msg, :yellow, newline) if level("warn") + + return tell_err(msg, :yellow, newline) if Bundler.feature_flag.error_on_stderr? + tell_me(msg, :yellow, newline) end def error(msg, newline = nil) diff --git a/spec/bundler/ui/shell_spec.rb b/spec/bundler/ui/shell_spec.rb index 6585ab1da8..9a47a3572f 100644 --- a/spec/bundler/ui/shell_spec.rb +++ b/spec/bundler/ui/shell_spec.rb @@ -21,9 +21,20 @@ RSpec.describe Bundler::UI::Shell do describe "#warn" do before { subject.level = "warn" } - it "prints to stdout" do + it "prints to stdout", :bundler => "< 2" do expect { subject.warn("warning") }.to output("warning\n").to_stdout end + + it "prints to stderr", :bundler => "2" do + expect { subject.warn("warning") }.to output("warning\n").to_stderr + end + + context "when stderr flag is enabled" do + before { Bundler.settings.temporary(:error_on_stderr => true) } + it "prints to stderr" do + expect { subject.warn("warning!") }.to output("warning!\n").to_stderr + end + end end describe "#debug" do @@ -35,7 +46,7 @@ RSpec.describe Bundler::UI::Shell do describe "#error" do before { subject.level = "error" } - it "prints to stdout", :bundler => "<= 2" do + it "prints to stdout", :bundler => "< 2" do expect { subject.error("error!!!") }.to output("error!!!\n").to_stdout end |