lib: support FORCE_COLOR for non TTY streams#48034
lib: support FORCE_COLOR for non TTY streams#48034nodejs-github-bot merged 5 commits intonodejs:mainfrom
FORCE_COLOR for non TTY streams#48034Conversation
|
Review requested:
|
test/parallel/test-repl-envvars.js
Outdated
| } | ||
|
|
||
| tests.forEach(run); | ||
| tests.forEach((testCase) => test(inspect(testCase.env), () => run(testCase))); |
There was a problem hiding this comment.
tests did not play well when running in parallel. used node:test to run them sequentially
|
/CC @nodejs/util @nodejs/console |
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: #48034 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
|
This broke tests when pulling into v18, so it needs a backport. |
|
@danielleadams It seems |
|
Talked to @MoLow offline, but staging branch is ready for backport now. |
PR-URL: nodejs#48034 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#48034 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#48034 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
PR-URL: nodejs#48034 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
|
@MoLow Small heads up, this seems to have broken |
|
@addaleax I am not able to reproduce this: |
|
@MoLow Yeah, |
This was historically done to make `console.log()` have colors. However, this makes any other code that checks `process.stdout.isTTY` incorrectly assume real TTY support. Node18 and Node20 now respect `FORCE_COLOR=1` in console, so our default behavior of forcing colors in the worker process just works out of the box. See nodejs/node#48034.

The current behavior of
FORCE_COLORis to take effect whenstdout/stderrare TTY'saccording to the documentation:
this PR moves the check for the value of
FORCE_COLORbefore testingisTTY- and extracts the logic to a central utility.Refs: #31409 (comment)