Skip to content

Commit

Permalink
Add NO_COLOR support https://no-color.org/ - fixes #91
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Jul 29, 2024
1 parent 9fd852b commit 1357f4a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,21 @@ const forceColor = isNode &&
f.isOneOf(process.env.FORCE_COLOR, ['true', '1', '2'])

/* c8 ignore start */
export const supportsColor = !hasParam('--no-colors') &&
(!isNode || process.stdout.isTTY || forceColor) && (
!isNode || hasParam('--color') || forceColor ||
/**
* Color is enabled by default if the terminal supports it.
*
* Explicitly enable color using `--color` parameter
* Disable color using `--no-color` parameter or using `NO_COLOR=1` environment variable.
* `FORCE_COLOR=1` enables color and takes precedence over all.
*/
export const supportsColor = forceColor || (
!hasParam('--no-colors') && // @todo deprecate --no-colors
!hasConf('no-color') &&
(!isNode || process.stdout.isTTY) && (
!isNode ||
hasParam('--color') ||
getVariable('COLORTERM') !== null ||
(getVariable('TERM') || '').includes('color')
)
)
/* c8 ignore stop */

0 comments on commit 1357f4a

Please sign in to comment.