mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
colorize.rb: support for NO_COLOR
This commit is contained in:
parent
f0c8c1e878
commit
99a79dc40b
1 changed files with 1 additions and 1 deletions
|
@ -7,7 +7,7 @@ class Colorize
|
|||
def initialize(color = nil, opts = ((_, color = color, nil)[0] if Hash === color))
|
||||
@colors = @reset = nil
|
||||
@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)
|
||||
@beg = "\e["
|
||||
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
|
||||
|
|
Loading…
Reference in a new issue