Skip to content

Commit 1d4d8b2

Browse files
committed
doc: document the NO_COLOR and FORCE_COLOR env vars
Signed-off-by: James M Snell <[email protected]> Fixes: #37404
1 parent eed3c72 commit 1d4d8b2

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

doc/api/cli.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,6 +1264,18 @@ Print node's version.
12641264

12651265
## Environment variables
12661266

1267+
### `FORCE_COLOR=[1, 2, 3]`
1268+
1269+
The `FORCE_COLOR` environment variable is used to
1270+
enable ANSI colorized output. The value may be:
1271+
1272+
* `1` or `true` to indicate 16-color support,
1273+
* `2` to indicate 256-color support, or
1274+
* `3` to indicate 16 million-color support.
1275+
1276+
When `FORCE_COLOR` is used and set to a supported value, both the `NO_COLOR`,
1277+
and `NODE_DISABLE_COLORS` environment variables are ignored.
1278+
12671279
### `NODE_DEBUG=module[,…]`
12681280
<!-- YAML
12691281
added: v0.1.32
@@ -1609,6 +1621,10 @@ and the line lengths of the source file (in the key `lineLengths`).
16091621
}
16101622
```
16111623

1624+
### `NO_COLOR=1`
1625+
1626+
[`NO_COLOR`][] is an alias for `NODE_DISABLE_COLORS`.
1627+
16121628
### `OPENSSL_CONF=file`
16131629
<!-- YAML
16141630
added: v6.11.0
@@ -1704,6 +1720,7 @@ $ node --max-old-space-size=1536 index.js
17041720
[`Buffer`]: buffer.md#buffer_class_buffer
17051721
[`CRYPTO_secure_malloc_init`]: https://www.openssl.org/docs/man1.1.0/man3/CRYPTO_secure_malloc_init.html
17061722
[`NODE_OPTIONS`]: #cli_node_options_options
1723+
[`NO_COLOR`]: https://no-color.org
17071724
[`SlowBuffer`]: buffer.md#buffer_class_slowbuffer
17081725
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#process_process_setuncaughtexceptioncapturecallback_fn
17091726
[`tls.DEFAULT_MAX_VERSION`]: tls.md#tls_tls_default_max_version

doc/node.1

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,23 @@ Print node's version.
530530
.\" =====================================================================
531531
.Sh ENVIRONMENT
532532
.Bl -tag -width 6n
533+
.It Ev FORCE_COLOR
534+
Used to enable ANSI colorized output. The value may be one of:
535+
.Ar 1
536+
or
537+
.Ar true
538+
to
539+
indicate 16-color support,
540+
.Ar 2
541+
to indicate 256-color support, or
542+
.Ar 3
543+
to indicate 16 million-color support. When used and set to a supported
544+
value, both the NO_COLOR and NODE_DISABLE_COLORS environment variables
545+
are ignored.
546+
.
547+
.It Ev NO_COLOR
548+
Alias for NODE_DISABLE_COLORS
549+
.
533550
.It Ev NODE_DEBUG Ar modules...
534551
Comma-separated list of core modules that should print debug information.
535552
.

lib/internal/main/print_help.js

Lines changed: 3 additions & 0 deletions
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, or 3, causes " +
33+
'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)