Skip to content

Commit 9fb3388

Browse files
committed
fixup! feat(core): surface the unsupported-version warning in CI
1 parent 664e6e9 commit 9fb3388

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

‎packages/core/src/nodeVersion.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ function escapeWorkflowCommandData(value: string): string {
2727
return value.replace(/%/g, "%25").replace(/\r/g, "%0D").replace(/\n/g, "%0A");
2828
}
2929

30+
/**
31+
* Properties are parsed out of the command header, where `:` ends the property
32+
* list and `,` separates properties, so both need encoding on top of the data
33+
* escaping.
34+
*/
35+
function escapeWorkflowCommandProperty(value: string): string {
36+
return escapeWorkflowCommandData(value)
37+
.replace(/:/g, "%3A")
38+
.replace(/,/g, "%2C");
39+
}
40+
3041
/** ANSI yellow, the colour GitLab CI job logs use for warnings. */
3142
const YELLOW = "\x1b[33m";
3243
const COLOR_RESET = "\x1b[0m";
@@ -42,7 +53,7 @@ const COLOR_RESET = "\x1b[0m";
4253
export function warnCi(message: string, title: string): void {
4354
if (process.env.GITHUB_ACTIONS === "true") {
4455
process.stdout.write(
45-
`::warning title=${escapeWorkflowCommandData(title)}::${escapeWorkflowCommandData(message)}\n`,
56+
`::warning title=${escapeWorkflowCommandProperty(title)}::${escapeWorkflowCommandData(message)}\n`,
4657
);
4758
return;
4859
}

‎packages/core/tests/nodeVersion.integ.test.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ describe("warnCi", () => {
4444
it("should emit an annotation on GitHub Actions", () => {
4545
process.env.GITHUB_ACTIONS = "true";
4646

47-
warnCi("a 100% clear\nwarning", "A title");
47+
warnCi("a 100% clear\nwarning", "A title: with, separators");
4848

4949
expect(write).toHaveBeenCalledWith(
50-
"::warning title=A title::a 100%25 clear%0Awarning\n",
50+
"::warning title=A title%3A with%2C separators::a 100%25 clear%0Awarning\n",
5151
);
5252
expect(warn).not.toHaveBeenCalled();
5353
});

0 commit comments

Comments
 (0)