Skip to content

Commit 20d513a

Browse files
themr0cclaude
andcommitted
fix: strip ANSI codes and use last capture group in error classification
Strip ANSI escape sequences before pattern matching so cause/fix messages don't contain terminal color codes from ccutil output. Use last capture group instead of first so multi-group patterns like invalid-xref extract the actual ID, not the alternation match. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7728cde commit 20d513a

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

build/scripts/build-orchestrator.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,20 @@ function loadErrorPatterns(patternsPath) {
8282
}));
8383
}
8484

85+
// eslint-disable-next-line no-control-regex
86+
const ANSI_RE = /\x1b\[[0-9;]*m/g;
87+
8588
function classifyErrors(output, patterns) {
8689
const errors = [];
8790
const lines = output.split('\n');
8891
for (const line of lines) {
92+
const clean = line.replace(ANSI_RE, '');
8993
for (const pattern of patterns) {
90-
const m = pattern.compiled.exec(line);
94+
const m = pattern.compiled.exec(clean);
9195
if (m) {
92-
const matchVal = m[m.length > 1 ? 1 : 0];
96+
const matchVal = m[m.length - 1];
9397
errors.push({
94-
line: line.trim(),
98+
line: clean.trim(),
9599
patternId: pattern.id,
96100
cause: pattern.cause.replace('{match}', matchVal),
97101
fix: pattern.fix.replace('{match}', matchVal),

0 commit comments

Comments
 (0)