core: only bold when output is part of a machine

This commit is contained in:
Mitchell Hashimoto 2014-01-20 16:37:06 -08:00
parent 714c690d8b
commit fc86a10796
2 changed files with 17 additions and 3 deletions

View File

@ -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

View File

@ -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