Skip to content

Commit 2168e95

Browse files
jasnelltargos
authored andcommitted
doc: document the NO_COLOR and FORCE_COLOR env vars
Signed-off-by: James M Snell <[email protected]> Fixes: #37404 PR-URL: #37477 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Juan José Arboleda <[email protected]> Reviewed-By: Rich Trott <[email protected]>
1 parent 241e057 commit 2168e95

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed

doc/api/cli.md

+19
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,19 @@ Print node's version.
11401140

11411141
## Environment variables
11421142

1143+
### `FORCE_COLOR=[1, 2, 3]`
1144+
1145+
The `FORCE_COLOR` environment variable is used to
1146+
enable ANSI colorized output. The value may be:
1147+
1148+
* `1`, `true`, or the empty string `''` indicate 16-color support,
1149+
* `2` to indicate 256-color support, or
1150+
* `3` to indicate 16 million-color support.
1151+
1152+
When `FORCE_COLOR` is used and set to a supported value, both the `NO_COLOR`,
1153+
and `NODE_DISABLE_COLORS` environment variables are ignored.
1154+
1155+
Any other value will result in colorized output being disabled.
11431156
### `NODE_DEBUG=module[,…]`
11441157
<!-- YAML
11451158
added: v0.1.32
@@ -1485,6 +1498,11 @@ and the line lengths of the source file (in the key `lineLengths`).
14851498
}
14861499
```
14871500

1501+
### `NO_COLOR=<any>`
1502+
1503+
[`NO_COLOR`][] is an alias for `NODE_DISABLE_COLORS`. The value of the
1504+
environment variable is arbitrary.
1505+
14881506
### `OPENSSL_CONF=file`
14891507
<!-- YAML
14901508
added: v6.11.0
@@ -1579,6 +1597,7 @@ $ node --max-old-space-size=1536 index.js
15791597
[`Atomics.wait()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics/wait
15801598
[`Buffer`]: buffer.md#buffer_class_buffer
15811599
[`NODE_OPTIONS`]: #cli_node_options_options
1600+
[`NO_COLOR`]: https://no-color.org
15821601
[`SlowBuffer`]: buffer.md#buffer_class_slowbuffer
15831602
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#process_process_setuncaughtexceptioncapturecallback_fn
15841603
[`tls.DEFAULT_MAX_VERSION`]: tls.md#tls_tls_default_max_version

doc/node.1

+20
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,26 @@ Print node's version.
518518
.\" =====================================================================
519519
.Sh ENVIRONMENT
520520
.Bl -tag -width 6n
521+
.It Ev FORCE_COLOR
522+
Used to enable ANSI colorized output. The value may be one of:
523+
.Ar 1
524+
,
525+
.Ar true
526+
, or
527+
.Ar an empty string
528+
to
529+
indicate 16-color support,
530+
.Ar 2
531+
to indicate 256-color support, or
532+
.Ar 3
533+
to indicate 16 million-color support. When used and set to a supported
534+
value, both the NO_COLOR and NODE_DISABLE_COLORS environment variables
535+
are ignored. Any other value will result in colorized output being
536+
disabled.
537+
.
538+
.It Ev NO_COLOR
539+
Alias for NODE_DISABLE_COLORS
540+
.
521541
.It Ev NODE_DEBUG Ar modules...
522542
Comma-separated list of core modules that should print debug information.
523543
.

lib/internal/main/print_help.js

+3
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ for (const key of ObjectKeys(types))
2929
// so we gather the documentation here.
3030
const { hasIntl, hasSmallICU, hasNodeOptions } = internalBinding('config');
3131
const envVars = new SafeMap(ArrayPrototypeConcat([
32+
['FORCE_COLOR', { helpText: "when set to 'true', 1, 2, 3, or an empty " +
33+
'string causes NO_COLOR and NODE_DISABLE_COLORS to be ignored.' }],
34+
['NO_COLOR', { helpText: 'Alias for NODE_DISABLE_COLORS' }],
3235
['NODE_DEBUG', { helpText: "','-separated list of core modules that " +
3336
'should print debug information' }],
3437
['NODE_DEBUG_NATIVE', { helpText: "','-separated list of C++ core debug " +

0 commit comments

Comments
 (0)