tty: add NO_COLOR and FORCE_COLOR support#26485
tty: add NO_COLOR and FORCE_COLOR support#26485BridgeAR wants to merge 2 commits intonodejs:masterfrom
Conversation
This adds support to enforce a specific color depth by checking the `FORCE_COLOR` environment variable similar to `chalk`. On top of that we also add support for the `NO_COLOR` environment variable as suggested by https://no-color.org/.
b1653fb to
af0b138
Compare
silverwind
left a comment
There was a problem hiding this comment.
LGTM, thought some sort of standardization attempt for FORCE_COLOR and especially its values would be nice.
|
@silverwind I am already working in that direction and opened issues in the |
vsemozhetbyt
left a comment
There was a problem hiding this comment.
Doc format LGTM with nits.
|
Resumed CI https://ci.nodejs.org/job/node-test-commit/26577/ ✔️ |
|
It would be nice to get some further reviews @nodejs/repl @nodejs/util |
| case '': | ||
| case '1': | ||
| case 'true': | ||
| warnOnDeactivatedColors(env); |
There was a problem hiding this comment.
Place this above the switch?
There was a problem hiding this comment.
When moved above the switch, I'll have to exclude a lot of values. That's why it's inside.
This adds support to enforce a specific color depth by checking the `FORCE_COLOR` environment variable similar to `chalk`. On top of that we also add support for the `NO_COLOR` environment variable as suggested by https://no-color.org/. PR-URL: nodejs#26485 Refs: nodejs#26248 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
|
Landed in 273398a 🎉 |
This adds support to enforce a specific color depth by checking the `FORCE_COLOR` environment variable similar to `chalk`. On top of that we also add support for the `NO_COLOR` environment variable as suggested by https://no-color.org/. PR-URL: nodejs#26485 Refs: nodejs#26248 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This adds support to enforce a specific color depth by checking the `FORCE_COLOR` environment variable similar to `chalk`. On top of that we also add support for the `NO_COLOR` environment variable as suggested by https://no-color.org/. PR-URL: #26485 Refs: #26248 Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Notable changes:
* events:
* Added a `once` function to use `EventEmitter` with promises
(#26078).
* tty:
* Added a `hasColors` method to `WriteStream`
(#26247).
* Added NO_COLOR and FORCE_COLOR support
(#26485).
* v8:
* Added `v8.getHeapSnapshot` and `v8.writeHeapSnapshot` to generate snapshots
in the format used by tools such as Chrome DevTools
(#26501).
* meta:
* Gireesh Punathil is now a member of the Technical Steering Committee
(#26657).
* Added ZYSzys to collaborators (#26730).
PR-URL: #26949
Notable changes:
* crypto
* Allow deriving public from private keys (Tobias Nießen)
[#26278](#26278).
* events
* Added a `once` function to use `EventEmitter` with promises
(Matteo Collina) [#26078](#26078).
* tty
* Added a `hasColors` method to `WriteStream` (Ruben Bridgewater)
[#26247](#26247).
* Added NO_COLOR and FORCE_COLOR support (Ruben Bridgewater)
[#26485](#26485).
* v8
* Added `v8.getHeapSnapshot` and `v8.writeHeapSnapshot` to generate snapshots
in the format used by tools such as Chrome DevTools (James M Snell)
[#26501](#26501).
* worker
* Added `worker.moveMessagePortToContext`. This enables using MessagePorts in
different vm.Contexts, aiding with the isolation that the vm module seeks to
provide (Anna Henningsen)
[#26497](#26497).
* C++ API
* `AddPromiseHook` is now deprecated. This API was added to fill an use case
that is served by `async_hooks`, since that has `Promise` support
(Anna Henningsen) [#26529](#26529).
* Added a `Stop` API to shut down Node.js while it is running
(Gireesh Punathil) [#21283](#21283).
* meta
* [Gireesh Punathil](https://github.com/gireeshpunathil) is now a member of
the Technical Steering Committee
[#26657](#26657).
* Added [Yongsheng Zhang](https://github.com/ZYSzys) to collaborators
[#26730](#26730).
PR-URL: #26949
Notable changes:
* crypto
* Allow deriving public from private keys (Tobias Nießen)
[#26278](#26278).
* events
* Added a `once` function to use `EventEmitter` with promises
(Matteo Collina) [#26078](#26078).
* tty
* Added a `hasColors` method to `WriteStream` (Ruben Bridgewater)
[#26247](#26247).
* Added NO_COLOR and FORCE_COLOR support (Ruben Bridgewater)
[#26485](#26485).
* v8
* Added `v8.getHeapSnapshot` and `v8.writeHeapSnapshot` to generate snapshots
in the format used by tools such as Chrome DevTools (James M Snell)
[#26501](#26501).
* worker
* Added `worker.moveMessagePortToContext`. This enables using MessagePorts in
different vm.Contexts, aiding with the isolation that the vm module seeks to
provide (Anna Henningsen)
[#26497](#26497).
* C++ API
* `AddPromiseHook` is now deprecated. This API was added to fill an use case
that is served by `async_hooks`, since that has `Promise` support
(Anna Henningsen) [#26529](#26529).
* Added a `Stop` API to shut down Node.js while it is running
(Gireesh Punathil) [#21283](#21283).
* meta
* [Gireesh Punathil](https://github.com/gireeshpunathil) is now a member of
the Technical Steering Committee
[#26657](#26657).
* Added [Yongsheng Zhang](https://github.com/ZYSzys) to collaborators
[#26730](#26730).
PR-URL: #26949
Notable changes:
* crypto
* Allow deriving public from private keys (Tobias Nießen)
[#26278](#26278).
* events
* Added a `once` function to use `EventEmitter` with promises
(Matteo Collina) [#26078](#26078).
* tty
* Added a `hasColors` method to `WriteStream` (Ruben Bridgewater)
[#26247](#26247).
* Added NO_COLOR and FORCE_COLOR support (Ruben Bridgewater)
[#26485](#26485).
* v8
* Added `v8.getHeapSnapshot` and `v8.writeHeapSnapshot` to generate snapshots
in the format used by tools such as Chrome DevTools (James M Snell)
[#26501](#26501).
* worker
* Added `worker.moveMessagePortToContext`. This enables using MessagePorts in
different vm.Contexts, aiding with the isolation that the vm module seeks to
provide (Anna Henningsen)
[#26497](#26497).
* C++ API
* `AddPromiseHook` is now deprecated. This API was added to fill an use case
that is served by `async_hooks`, since that has `Promise` support
(Anna Henningsen) [#26529](#26529).
* Added a `Stop` API to shut down Node.js while it is running
(Gireesh Punathil) [#21283](#21283).
* meta
* [Gireesh Punathil](https://github.com/gireeshpunathil) is now a member of
the Technical Steering Committee
[#26657](#26657).
* Added [Yongsheng Zhang](https://github.com/ZYSzys) to collaborators
[#26730](#26730).
PR-URL: #26949

This adds support to enforce a specific color depth by checking the
FORCE_COLORenvironment variable similar tochalk.On top of that we also add support for the
NO_COLORenvironmentvariable as suggested by https://no-color.org/.
Refs: #26248
This supersedes #26248.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes