Add 'auto' mode that only adds colors for the terminal #34

Closed
wants to merge 1 commit into
from

Projects

None yet

7 participants

@danielbeardsley

If the mode is set to 'auto', then escaping will only happen if stdout is a TTY
(terminal). If stdout is redirected somewhere, strings will not be modified by
the colorize functions.

@danielbeardsley danielbeardsley Add 'auto' mode that only adds colors for the terminal
If the mode is set to 'auto', then escaping will only happen if stdout is a TTY
(terminal).  If stdout is redirected somewhere, strings will not be modified by
the colorize functions.
922384e
@clarkbox clarkbox referenced this pull request in clarkbox/testswarm-browserstack Nov 14, 2012
Closed

Avoid outputting console color codes to log files #34

@Marak
Owner
Marak commented Jan 5, 2013

@danielbeardsley - I'm not against adding this, but it seems it might be a bit more straight forward for the developer to handle this on their own instead of having colors do it.

@danielbeardsley

You're saying have an enabled option that you can set to false? We could support setting mode to always, never, and 'auto'. never mind that suggestion, that's what we already have.

I feel the like the 99% use-case is turning off colors if the output is being piped (which this does). So it makes sense to me to add a few lines of code to make it easy on most users.

@jakl
jakl commented Sep 28, 2013

+1

@rodrigok

+1

@Ackar
Ackar commented Jul 2, 2014

+1

Also, I think it would be better if all of this was done automatically without having to set the mode to 'auto'.
In the vast majority of cases you don't want colors if you're not on a TTY, and you can still set the mode manually if you have particular needs.

It's a simple feature but it would be really nice to have...

@stevenvachon
Contributor

@Marak hasn't this been implemented in v1.0 ?

@pksunkara
Collaborator

Yes, this has been implemented in v1.0. If the process.stdout is a TTY, the output will be colored, otherwise not.

@pksunkara pksunkara closed this Jan 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment