Skip to content

Commit f17d00e

Browse files
committed
fix(core): handle FORCE_COLOR=0 with picocolors (#34520)
## Current Behavior After migrating from chalk to picocolors (#34305), `FORCE_COLOR=0` no longer disables colors. picocolors checks `!!env.FORCE_COLOR`, and since `!!"0"` is `true` in JavaScript, it treats `FORCE_COLOR=0` as "enable colors." This breaks CI environments and tools like Homebrew that set `FORCE_COLOR=0` to get plain text output. ## Expected Behavior `FORCE_COLOR=0` should disable ANSI color output, matching the previous chalk behavior and the [FORCE_COLOR spec](https://force-color.org/). ## Related Issue(s) Fixes #34387 Upstream issue filed: alexeyraspopov/picocolors#100 (cherry picked from commit f31e7a7)
1 parent d3ff964 commit f17d00e

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

packages/nx/bin/nx.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
#!/usr/bin/env node
2+
3+
// TODO: Remove this workaround once picocolors handles FORCE_COLOR=0 correctly
4+
// See: https://github.com/alexeyraspopov/picocolors/issues/100
5+
if (process.env.FORCE_COLOR === '0') {
6+
process.env.NO_COLOR = '1';
7+
delete process.env.FORCE_COLOR;
8+
}
9+
210
import {
311
findWorkspaceRoot,
412
WorkspaceTypeAndRoot,

0 commit comments

Comments
 (0)