diff --git a/lib/vagrant/ui.rb b/lib/vagrant/ui.rb index a16da0990..7dfd171cf 100644 --- a/lib/vagrant/ui.rb +++ b/lib/vagrant/ui.rb @@ -288,6 +288,9 @@ module Vagrant opts = @opts.merge(opts) + # Default the bold option if its not given + opts[:bold] = type == :output if !opts.has_key?(:bold) + # Special case some colors for certain message types opts[:color] = :red if type == :error opts[:color] = :yellow if type == :warn @@ -297,7 +300,7 @@ module Vagrant # If it is a detail, it is not bold. Every other message type # is bolded. - bold = type != :detail + bold = !!opts[:bold] color = COLORS[opts[:color]] # Color the message and make sure to reset the color at the end diff --git a/test/unit/vagrant/ui_test.rb b/test/unit/vagrant/ui_test.rb index 50ded7798..ba5af8a4f 100644 --- a/test/unit/vagrant/ui_test.rb +++ b/test/unit/vagrant/ui_test.rb @@ -129,7 +129,7 @@ describe Vagrant::UI::Colored do describe "#error" do it "colors red" do subject.should_receive(:safe_puts).with do |message, *args| - expect(message).to start_with("\033[1;31m") + expect(message).to start_with("\033[0;31m") expect(message).to end_with("\033[0m") end @@ -164,12 +164,23 @@ describe Vagrant::UI::Colored do subject.output("foo", color: :green) end + + it "doesn't bold the output if specified" do + subject.opts[:color] = :red + + subject.should_receive(:safe_puts).with do |message, *args| + expect(message).to start_with("\033[0;31m") + expect(message).to end_with("\033[0m") + end + + subject.output("foo", bold: false) + end end describe "#warn" do it "colors yellow" do subject.should_receive(:safe_puts).with do |message, *args| - expect(message).to start_with("\033[1;33m") + expect(message).to start_with("\033[0;33m") expect(message).to end_with("\033[0m") end