colorize.rb: support for NO_COLOR
This commit is contained in:
parent
f0c8c1e878
commit
99a79dc40b
@ -7,7 +7,7 @@ class Colorize
|
|||||||
def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
|
def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
|
||||||
@colors = @reset = nil
|
@colors = @reset = nil
|
||||||
@color = (opts[:color] if opts)
|
@color = (opts[:color] if opts)
|
||||||
if color or (color == nil && STDOUT.tty?)
|
if color or (color == nil && STDOUT.tty? && (ENV["NO_COLOR"] || "").empty?)
|
||||||
if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", :err => IO::NULL, &:read)} rescue nil)
|
if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", :err => IO::NULL, &:read)} rescue nil)
|
||||||
@beg = "\e["
|
@beg = "\e["
|
||||||
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user