Skip to content

Commit

Permalink
doc: document the NO_COLOR and FORCE_COLOR env vars
Browse files Browse the repository at this point in the history
Signed-off-by: James M Snell <jasnell@gmail.com>
Fixes: nodejs#37404
  • Loading branch information
jasnell committed Feb 22, 2021
1 parent f3eb224 commit b76f556
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/api/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -1257,6 +1257,19 @@ Print node's version.

## Environment variables

### `FORCE_COLOR=[1, 2, 3]`

The `FORCE_COLOR` environment variable was first introduced by modules in
the Node.js ecosystem before being introduced into Node.js. It is used to
enable ANSI colorized output. The value may be:

* `1` or `true` to indicate 16-color support,
* `2` to indicate 256-color support, or
* `3` to indicate 16 million-color support.

When `FORCE_COLOR` is used and set to a supported value, both the `NO_COLOR`,
and `NODE_DISABLE_COLORS` environment variables are ignored.

### `NODE_DEBUG=module[,…]`
<!-- YAML
added: v0.1.32
Expand Down Expand Up @@ -1602,6 +1615,12 @@ and the line lengths of the source file (in the key `lineLengths`).
}
```

### `NO_COLOR=1`

The [`NO_COLOR`][] environment variable is an informal standard supported by
growing number of applications for disabling ANSI color escape codes. Within
Node.js, `NO_COLOR` is an alias for `NODE_DISABLE_COLORS`.

### `OPENSSL_CONF=file`
<!-- YAML
added: v6.11.0
Expand Down Expand Up @@ -1697,6 +1716,7 @@ $ node --max-old-space-size=1536 index.js
[`Buffer`]: buffer.md#buffer_class_buffer
[`CRYPTO_secure_malloc_init`]: https://www.openssl.org/docs/man1.1.0/man3/CRYPTO_secure_malloc_init.html
[`NODE_OPTIONS`]: #cli_node_options_options
[`NO_COLOR`]: https://no-color.org
[`SlowBuffer`]: buffer.md#buffer_class_slowbuffer
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#process_process_setuncaughtexceptioncapturecallback_fn
[`tls.DEFAULT_MAX_VERSION`]: tls.md#tls_tls_default_max_version
Expand Down
3 changes: 3 additions & 0 deletions lib/internal/main/print_help.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ for (const key of ObjectKeys(types))
// so we gather the documentation here.
const { hasIntl, hasSmallICU, hasNodeOptions } = internalBinding('config');
const envVars = new SafeMap(ArrayPrototypeConcat([
['FORCE_COLOR', { helpText: "when set to 'true', 1, 2, or 3, causes " +
'NO_COLOR and NODE_DISABLE_COLORS to be ignored.' }],
['NO_COLOR', { helpText: 'Alias for NODE_DISABLE_COLORS' }],
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
'should print debug information' }],
['NODE_DEBUG_NATIVE', { helpText: "','-separated list of C++ core debug " +
Expand Down

0 comments on commit b76f556

Please sign in to comment.