I try to pipe the output from a command line command through Ruby.
It works fine but the coloring is missing.
How can I preserve the coloring?
This is what my code looks like:
cmd = "cucumber #{ARGV.join(" ")}"
IO.popen(cmd) do |io|
io.each { |s| print s }
end
Updated:
The premise of the question was wrong – IO.popen does preserve the colors.
Run cucumber with the
-coption. Otherwise cucumber determines that the terminal (the pipe) does not support coloring and will drop it if not explicitly forced on with-c.https://github.com/cucumber/cucumber/blob/master/lib/cucumber/cli/options.rb#L211