Skip to content

Commit

Permalink
colorize.rb: fix reading from test/colors
Browse files Browse the repository at this point in the history
[ci skip]
  • Loading branch information
nobu committed Jun 4, 2019
1 parent 16cb1fb commit b0c35ff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tool/colorize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ def initialize(color = nil)
if color or (color == nil && STDOUT.tty?)
if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", err: IO::NULL, &:read) rescue nil)
@beg = "\e["
@colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
begin
File.read(File.join(__dir__, "../test/colors")).scan(/(\w+)=([^:\n]*)/) do |n, c|
colors[n] ||= c
end
rescue
rescue Errno::ENOENT
end
@colors = colors
@reset = "#{@beg}m"
end
end
Expand Down

0 comments on commit b0c35ff

Please sign in to comment.