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.
Add 'auto' mode that only adds colors for the terminal
@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.
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.
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...
@Marak hasn't this been implemented in v1.0 ?
Yes, this has been implemented in v1.0. If the process.stdout is a TTY, the output will be colored, otherwise not.