core: only bold when output is part of a machine
This commit is contained in:
parent
714c690d8b
commit
fc86a10796
|
@ -288,6 +288,9 @@ module Vagrant
|
||||||
|
|
||||||
opts = @opts.merge(opts)
|
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
|
# Special case some colors for certain message types
|
||||||
opts[:color] = :red if type == :error
|
opts[:color] = :red if type == :error
|
||||||
opts[:color] = :yellow if type == :warn
|
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
|
# If it is a detail, it is not bold. Every other message type
|
||||||
# is bolded.
|
# is bolded.
|
||||||
bold = type != :detail
|
bold = !!opts[:bold]
|
||||||
color = COLORS[opts[:color]]
|
color = COLORS[opts[:color]]
|
||||||
|
|
||||||
# Color the message and make sure to reset the color at the end
|
# Color the message and make sure to reset the color at the end
|
||||||
|
|
|
@ -129,7 +129,7 @@ describe Vagrant::UI::Colored do
|
||||||
describe "#error" do
|
describe "#error" do
|
||||||
it "colors red" do
|
it "colors red" do
|
||||||
subject.should_receive(:safe_puts).with do |message, *args|
|
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")
|
expect(message).to end_with("\033[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -164,12 +164,23 @@ describe Vagrant::UI::Colored do
|
||||||
|
|
||||||
subject.output("foo", color: :green)
|
subject.output("foo", color: :green)
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#warn" do
|
describe "#warn" do
|
||||||
it "colors yellow" do
|
it "colors yellow" do
|
||||||
subject.should_receive(:safe_puts).with do |message, *args|
|
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")
|
expect(message).to end_with("\033[0m")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue