Respect the NO_COLOR
environment variable
#102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This addresses #85, potentially closing it.
I updated the implementation of the coloring logic in this project to respect the
NO_COLOR
environment variable name to allow users to use the tool without colored output. An alternative approach could be to use an existing library for coloring, which might just support these kinds of features.I briefly looked at adding a
--no-color
option1 and while this seems trivial the use ofconsole.error
(example) makes this non-trivial because every invocation would need to check--no-color
(whereas it does respectNO_COLOR
). Since I don't think it makes sense to perform this check every timeconsole.error
(or similar) is used, I think a larger refactoring of outputting is instead required if we want to support a flag like--no-color
.Footnotes
A basic implementation can be achieved by adding
.option('--no-color', 'Disable colored output.')
toindex.ts
and|| process.argv.includes('--no-color')
tocolor.ts
. ↩