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 end
def colorize(string, color_value) def colorize(string, color_value)
if ENV['NO_COLOR'] if use_colors?
string
else
color(color_value) + string + color(COLORS[:clear]) color(color_value) + string + color(COLORS[:clear])
else
string
end end
end end
def color(color_value) def color(color_value)
"\e[#{color_value}m" "\e[#{color_value}m"
end 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 end
class Sensei class Sensei

View File

@@ -93,16 +93,29 @@ module EdgeCase
end end
def colorize(string, color_value) def colorize(string, color_value)
if ENV['NO_COLOR'] if use_colors?
string
else
color(color_value) + string + color(COLORS[:clear]) color(color_value) + string + color(COLORS[:clear])
else
string
end end
end end
def color(color_value) def color(color_value)
"\e[#{color_value}m" "\e[#{color_value}m"
end 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 end
class Sensei class Sensei