fix(core): preserve FORCE_COLOR=0 intent for forked child tasks#35293
Open
comp615 wants to merge 1 commit intonrwl:masterfrom
Open
fix(core): preserve FORCE_COLOR=0 intent for forked child tasks#35293comp615 wants to merge 1 commit intonrwl:masterfrom
comp615 wants to merge 1 commit intonrwl:masterfrom
Conversation
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
a314699 to
901bd05
Compare
Contributor
Author
|
@FrozenPandaz FYI Also note that I think it might be OK if force-color true wasn't set in CI |
AgentEnder
approved these changes
Apr 17, 2026
When FORCE_COLOR=0 is set in the environment, bin/nx.ts deletes it (workaround for picocolors treating '0' as truthy). However, task-env.ts and task-orchestrator.ts then default the undefined FORCE_COLOR to 'true' for all forked children, re-enabling ANSI colors. Save the original FORCE_COLOR value in NX_ORIGINAL_FORCE_COLOR before deleting, and consult it when building child process environments. Extract the logic into a shared getForceColorForChild() helper. Fixes nrwl#35292 Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019d8c4e-0d90-7126-b438-be77211ef603
901bd05 to
4bcdfac
Compare
Contributor
|
View your CI Pipeline Execution ↗ for commit 4bcdfac
☁️ Nx Cloud last updated this comment at |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Current Behavior
When
FORCE_COLOR=0is set (common in CI to suppress ANSI codes),bin/nx.tsdeletes it fromprocess.envas a workaround for picocolors#100. However,task-env.tsandtask-orchestrator.tsthen default the undefinedFORCE_COLORto'true'for all forked child tasks, re-enabling ANSI colors in every child process.Expected Behavior
FORCE_COLOR=0should propagate to child tasks, resulting in no ANSI escape codes.Solution
bin/nx.ts: Save the original value inNX_ORIGINAL_FORCE_COLORbefore deletingtask-env.ts: Extract agetForceColorForChild()helper that checksNX_ORIGINAL_FORCE_COLORwhenFORCE_COLORis undefinedtask-orchestrator.ts: Use the shared helper at both call sitesImpact
This affects any CI environment that sets
FORCE_COLOR=0. In our case, ANSI escape codes in ESLint output broke downstream log parsers that use regex to extract lint errors (the✖ N problemssummary line contains invisible ANSI bytes that prevent matching).Tests
Added 4 unit tests for
getForceColorForChild()covering:FORCE_COLORpassthroughFORCE_COLOR=0→ deleted → restored viaNX_ORIGINAL_FORCE_COLOR'true'when neither is setFORCE_COLORtakes precedence overNX_ORIGINAL_FORCE_COLORFixes #35292
🤖 This PR was drafted with the help of AI