Disabled colored output on windows.

This commit is contained in:
Jim Weirich
2010-10-21 07:05:06 -04:00
parent 1864c9c346
commit 71f670ac1d
2 changed files with 32 additions and 6 deletions

View File

@@ -93,16 +93,29 @@ module EdgeCase
end
def colorize(string, color_value)
if ENV['NO_COLOR']
string
else
if use_colors?
color(color_value) + string + color(COLORS[:clear])
else
string
end
end
def color(color_value)
"\e[#{color_value}m"
end
def use_colors?
return false if ENV['NO_COLOR']
if ENV['ANSI_COLOR'].nil?
! using_windows?
else
ENV['ANSI_COLOR'] =~ /^(t|y)/i
end
end
def using_windows?
File::ALT_SEPARATOR
end
end
class Sensei

View File

@@ -93,16 +93,29 @@ module EdgeCase
end
def colorize(string, color_value)
if ENV['NO_COLOR']
string
else
if use_colors?
color(color_value) + string + color(COLORS[:clear])
else
string
end
end
def color(color_value)
"\e[#{color_value}m"
end
def use_colors?
return false if ENV['NO_COLOR']
if ENV['ANSI_COLOR'].nil?
! using_windows?
else
ENV['ANSI_COLOR'] =~ /^(t|y)/i
end
end
def using_windows?
File::ALT_SEPARATOR
end
end
class Sensei