Repository navigation
DO-2060: strip ANSI colour codes from the CDK diff output - #210
Merged
Merged
Conversation
When diff-command runs through Nx, CDK can still output colour even with --no-color. Nx runs tasks in a pseudo-terminal, and targets with "color": true set FORCE_COLOR. Nx also colours its own lines. The escape codes ended up in deployment-diff.txt, the PR comment and the GitHub notification emails. Set FORCE_COLOR=0 and NO_COLOR=1 on the diff step to stop most colour at the source, then strip any escape codes that are left with sed. This fixes every caller without changing each Nx project's config. It also stops a colour code from breaking the "There were no differences" check. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AdamJHall
approved these changes
Nov 20, 2026
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.
Description of the proposed changes
Context
When
diff-commandruns through Nx, the CDK diff output keeps its ANSI colour codes even with--no-color. Nx runs tasks in a pseudo-terminal, targets with"color": truesetFORCE_COLOR, and Nx colours its own lines too. The codes end up indeployment-diff.txt, the PR comment and the GitHub notification emails, making them hard to read (see aligent/opal-fibre-int#15).Changes
Strip colour from the CDK diff in
aws-cdk.yml, so every caller is fixed without changing each Nx project's config:FORCE_COLOR=0andNO_COLOR=1on the "Generate deployment diff" step, to stop most colour at the source.diff_outputwithsed, before it's written todeployment-diff.txtand checked withgrep. This also stops a colour code from breaking the "There were no differences" check.Test
ubuntu:24.04container, run thesedline on sample output containing bold, colour, reset and clear-line codes. Check that no escape characters are left and the text is unchanged.Screenshots (if applicable)
Other solutions considered (if any)
ciconfiguration with"color": falseto each Nx project (aligent/opal-fibre-int#15): this works, but needs a change in every Nx project, and any project that misses it still has the problem. It also doesn't remove Nx's own colour codes.echoto the step log: the Actions log renders ANSI codes as colour, so only the diff file and thegrepchecks need the stripped text. Not done, because withFORCE_COLOR=0set, the only colour left to keep would come from Nx targets withcolor: true.Notes to PR author
Notes to reviewers
Time Tracking
DO-2060: code review, select projectXXXX🤖 Generated with Claude Code