Repository navigation
fix(toolkit-lib): whitespace is not trimmed from colored messages - #2047
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2047 +/- ##
==========================================
- Coverage 92.09% 92.05% -0.05%
==========================================
Files 82 83 +1
Lines 13184 13246 +62
Branches 1877 1884 +7
==========================================
+ Hits 12142 12193 +51
- Misses 1004 1015 +11
Partials 38 38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Head branch was pushed to by a user without write access
|
Automated review A maintainer will still review this — treat the notes below as a starting point. 📌 Commit This PR fixes a color-dependent whitespace-trimming bug in the toolkit-lib message pipeline ( 🔴 0 blocking · 🟡 0 recommended · ⚪ 0 optional Generated automatically. React 👍 or 👎 to tell us whether this review helped, so we can improve these reviews. |
Fixes #2085
The refactor and destroy IO snapshot tests pass in CI but fail when jest is run directly, as in
npx jest test/commands/destroy.test.ts. The difference is color support.nx run-manysetsFORCE_COLORfor every task, so in CI chalk wraps messages in color codes. The Toolkit trims whitespace around each message, but with color on, a leading or trailing newline sits inside the color codes andtrim()does not see it. So colored messages keep the newline and plain ones lose it, and the committed snapshots only match the colored run.withTrimmedWhitespacenow also trims whitespace that sits between the color codes at either end of a message, and keeps the codes. Messages come out the same with or without color. I added a test for this in toolkit-lib and updated the 20 refactor/destroy snapshots, which now pass withFORCE_COLORunset,0and1.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license