Skip to content

Commit 15e4f4f

Browse files
committed
fixup! fix(@angular/cli): strip terminal escape sequences in modern yarn error parser
1 parent bfe55df commit 15e4f4f

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

‎packages/angular/cli/src/package-managers/parsers.ts‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -697,21 +697,14 @@ export function parseYarnModernError(output: string, logger?: Logger): ErrorInfo
697697
}
698698
}
699699

700-
const [first, ...rest] = messages;
700+
const [first] = messages;
701701
const code = statusCode ? `E${statusCode}` : first.code;
702702
logger?.debug(` Successfully parsed modern yarn error with code '${code}'.`);
703703

704-
const [summary = '', ...firstDetailLines] = first.data
705-
.split('\n')
704+
const [summary = `Package manager error: ${code}`, ...detailLines] = messages
705+
.flatMap(({ data }) => data.split('\n'))
706706
.map((line) => line.trim())
707707
.filter(Boolean);
708-
const detailLines = [
709-
...firstDetailLines,
710-
...rest
711-
.flatMap(({ data }) => data.split('\n'))
712-
.map((line) => line.trim())
713-
.filter(Boolean),
714-
];
715708

716709
return {
717710
code,

‎packages/angular/cli/src/package-managers/parsers_spec.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,15 @@ project node_modules
732732
});
733733
});
734734

735+
it('should provide a fallback summary when error data is empty or whitespace-only', () => {
736+
const stdout = '{"type":"error","name":35,"displayName":"YN0035","indent":"","data":" "}';
737+
expect(parseYarnModernError(stdout)).toEqual({
738+
code: 'YN0035',
739+
summary: 'Package manager error: YN0035',
740+
detail: undefined,
741+
});
742+
});
743+
735744
it('should return null for successful, empty, or unrecognized output', () => {
736745
expect(parseYarnModernError('{"name":"@angular/core","version":"22.2.4"}')).toBeNull();
737746
expect(parseYarnModernError('"@angular/core@npm:22.2.4"\n"rxjs@npm:7.8.2"')).toBeNull();

0 commit comments

Comments
 (0)