Do not output color if stdout is not a TTY
This commit is contained in:
parent
2bd0b76fd2
commit
d753b750e9
|
@ -5,6 +5,8 @@
|
||||||
- Support for basic HTTP auth in the URL for boxes.
|
- Support for basic HTTP auth in the URL for boxes.
|
||||||
- Solaris support for host only networks. [GH-533]
|
- Solaris support for host only networks. [GH-533]
|
||||||
- `vagrant init` respects `Vagrant::Environment` cwd. [GH-528]
|
- `vagrant init` respects `Vagrant::Environment` cwd. [GH-528]
|
||||||
|
- `vagrant` commands will not output color when stdout is
|
||||||
|
not a TTY.
|
||||||
|
|
||||||
## 0.8.7 (September 13, 2011)
|
## 0.8.7 (September 13, 2011)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,12 @@ begin
|
||||||
env.logger.info("vagrant") { "`vagrant` invoked: #{ARGV.inspect}" }
|
env.logger.info("vagrant") { "`vagrant` invoked: #{ARGV.inspect}" }
|
||||||
|
|
||||||
# Disable color if the proper argument was passed
|
# Disable color if the proper argument was passed
|
||||||
shell = ARGV.include?("--no-color") ? Thor::Shell::Basic.new : Thor::Base.shell.new
|
shell = nil
|
||||||
|
if !$stdout.tty? || ARGV.include?("--no-color")
|
||||||
|
shell = Thor::Shell::Basic.new
|
||||||
|
else
|
||||||
|
shell = Thor::Base.shell.new
|
||||||
|
end
|
||||||
|
|
||||||
# Set the UI early in case any errors are raised, and load
|
# Set the UI early in case any errors are raised, and load
|
||||||
# the config immediately, so we gather any new commands from
|
# the config immediately, so we gather any new commands from
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
require File.expand_path("../base", __FILE__)
|
||||||
|
|
||||||
|
class VagrantTest < AcceptanceTest
|
||||||
|
should "not output color in the absense of a TTY" do
|
||||||
|
# This should always output an erorr, which on a TTY would
|
||||||
|
# output color. We check that this doesn't output color.
|
||||||
|
# If `vagrant status` itself is broken, another acceptance test
|
||||||
|
# should catch that. We just assume it works here.
|
||||||
|
result = execute("vagrant", "status")
|
||||||
|
assert(result.stdout.read !~ /\e\[31/, "output should not contain color")
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue