Skip to content

Commit 3b7cb75

Browse files
jasnelltargos
authored andcommitted
doc: document the NO_COLOR and FORCE_COLOR env vars
Signed-off-by: James M Snell <jasnell@gmail.com> Fixes: #37404 PR-URL: #37477 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 0fac27d commit 3b7cb75

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
@@ -1264,6 +1264,19 @@ 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`, `true`, or the empty string `''` 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+
1279+
Any other value will result in colorized output being disabled.
12671280
### `NODE_DEBUG=module[,…]`
12681281
<!-- YAML
12691282
added: v0.1.32
@@ -1609,6 +1622,11 @@ and the line lengths of the source file (in the key `lineLengths`).
16091622
}
16101623
```
16111624

1625+
### `NO_COLOR=<any>`
1626+
1627+
[`NO_COLOR`][] is an alias for `NODE_DISABLE_COLORS`. The value of the
1628+
environment variable is arbitrary.
1629+
16121630
### `OPENSSL_CONF=file`
16131631
<!-- YAML
16141632
added: v6.11.0
@@ -1704,6 +1722,7 @@ $ node --max-old-space-size=1536 index.js
17041722
[`Buffer`]: buffer.md#buffer_class_buffer
17051723
[`CRYPTO_secure_malloc_init`]: https://www.openssl.org/docs/man1.1.0/man3/CRYPTO_secure_malloc_init.html
17061724
[`NODE_OPTIONS`]: #cli_node_options_options
1725+
[`NO_COLOR`]: https://no-color.org
17071726
[`SlowBuffer`]: buffer.md#buffer_class_slowbuffer
17081727
[`process.setUncaughtExceptionCaptureCallback()`]: process.md#process_process_setuncaughtexceptioncapturecallback_fn
17091728
[`tls.DEFAULT_MAX_VERSION`]: tls.md#tls_tls_default_max_version

doc/node.1

+20
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,26 @@ 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+
,
537+
.Ar true
538+
, or
539+
.Ar an empty string
540+
to
541+
indicate 16-color support,
542+
.Ar 2
543+
to indicate 256-color support, or
544+
.Ar 3
545+
to indicate 16 million-color support. When used and set to a supported
546+
value, both the NO_COLOR and NODE_DISABLE_COLORS environment variables
547+
are ignored. Any other value will result in colorized output being
548+
disabled.
549+
.
550+
.It Ev NO_COLOR
551+
Alias for NODE_DISABLE_COLORS
552+
.
533553
.It Ev NODE_DEBUG Ar modules...
534554
Comma-separated list of core modules that should print debug information.
535555
.

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)