Always colorize Cygwin output

This commit is contained in:
Mitchell Hashimoto 2013-04-06 16:03:25 -07:00
parent fbdd46a130
commit fb9c311b4d
3 changed files with 29 additions and 9 deletions

View File

@ -33,6 +33,8 @@ FEATURES:
IMPROVEMENTS: IMPROVEMENTS:
- Full Windows support in cmd.exe, PowerShell, Cygwin, and MingW based
environments.
- By adding the "disabled" boolean flag to synced folders you can disable - By adding the "disabled" boolean flag to synced folders you can disable
them altogether. [GH-1004] them altogether. [GH-1004]
- Specify the default provider with the `VAGRANT_DEFAULT_PROVIDER` - Specify the default provider with the `VAGRANT_DEFAULT_PROVIDER`
@ -45,6 +47,8 @@ BUG FIXES:
- Don't preserve modified time when untarring boxes. [GH-1539] - Don't preserve modified time when untarring boxes. [GH-1539]
- Forwarded port auto-correct will not auto-correct to a port - Forwarded port auto-correct will not auto-correct to a port
that is also in use. that is also in use.
- Cygwin will always output color by default. Specify `--no-color` to
override this.
## 1.1.6 (April 3, 2013) ## 1.1.6 (April 3, 2013)

View File

@ -22,17 +22,32 @@ $stderr.sync = true
# environment. # environment.
opts = {} opts = {}
# Disable color if the proper argument was passed or if we're # Disable color in a few cases:
# on Windows since the default Windows terminal doesn't support #
# colors. # * --no-color is anywhere in our arguments
if ARGV.include?("--no-color") || !$stdout.tty? || !Vagrant::Util::Platform.terminal_supports_colors? # * STDOUT is not a TTY
# Delete the argument from the list so that it doesn't cause any # * The terminal doesn't support colors (Windows)
# invalid arguments down the road. #
if ARGV.include?("--no-color")
# Delete the argument from the list so that it doesn't
# cause any invalid arguments down the road.
ARGV.delete("--no-color") ARGV.delete("--no-color")
opts[:ui_class] = Vagrant::UI::Basic
elsif !Vagrant::Util::Platform.terminal_supports_colors?
opts[:ui_class] = Vagrant::UI::Basic
elsif !$stdout.tty?
# If we're not a TTY, verify we're not in Cygwin. Cygwin always
# reports that stdout is not a TTY, when in fact it is.
ENV["VAGRANT_DETECTED_OS"] ||= ""
if !ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")
opts[:ui_class] = Vagrant::UI::Basic opts[:ui_class] = Vagrant::UI::Basic
else
opts[:ui_class] = Vagrant::UI::Colored
end end
end
# Default to colored output
opts[:ui_class] ||= Vagrant::UI::Colored
# This is kind of hacky, and I'd love to find a better way to do this, but # This is kind of hacky, and I'd love to find a better way to do this, but
# if we're accessing the plugin interface, we want to NOT load plugins # if we're accessing the plugin interface, we want to NOT load plugins

View File

@ -67,7 +67,8 @@ module Vagrant
# output. # output.
def terminal_supports_colors? def terminal_supports_colors?
if windows? if windows?
return ENV.has_key?("ANSICON") return ENV.has_key?("ANSICON") ||
ENV["VAGRANT_DETECTED_OS"].downcase.include?("cygwin")
end end
true true