summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColby Swandale <colby@taplaboratories.com>2017-05-21 20:22:29 +1000
committerColby Swandale <colby@taplaboratories.com>2017-05-21 20:22:29 +1000
commit128d304ae6a43a83ed710ef483c0a5e3e97b4ac5 (patch)
tree04e82be8d6fc631af00fa6d51bbee24825ec05e0
parentdc39cb2cd115fd124493b8ab04a21a4ece5d1cf9 (diff)
downloadbundler-128d304ae6a43a83ed710ef483c0a5e3e97b4ac5.tar.gz
fix newline not being added correctly when printing to stderr
-rw-r--r--lib/bundler/ui/shell.rb3
-rw-r--r--spec/bundler/ui/shell_spec.rb2
2 files changed, 4 insertions, 1 deletions
diff --git a/lib/bundler/ui/shell.rb b/lib/bundler/ui/shell.rb
index 24429d1229..81743ede40 100644
--- a/lib/bundler/ui/shell.rb
+++ b/lib/bundler/ui/shell.rb
@@ -105,6 +105,9 @@ module Bundler
end
def tell_err(message, color = nil, newline = nil)
+ newline = message.to_s !~ /( |\t)\Z/ unless newline
+ message = word_wrap(message) if newline.is_a?(Hash) && newline[:wrap]
+
buffer = @shell.send(:prepare_message, message, *color)
buffer << "\n" if newline && !message.to_s.end_with?("\n")
diff --git a/spec/bundler/ui/shell_spec.rb b/spec/bundler/ui/shell_spec.rb
index b33cddab86..2db2d28641 100644
--- a/spec/bundler/ui/shell_spec.rb
+++ b/spec/bundler/ui/shell_spec.rb
@@ -42,7 +42,7 @@ RSpec.describe Bundler::UI::Shell do
context "when stderr flag is enabled" do
before { bundle "config error_on_stderr true" }
it "prints to stderr" do
- expect { subject.error("error!!!") }.to output("\e[31merror!!!\e[0m").to_stderr
+ expect { subject.error("error!!!") }.to output("\e[31merror!!!\e[0m\n").to_stderr
end
end
end