Skip to content

Commit b246e56

Browse files
committed
Use ExitCode instead of 0/1
1 parent bffae1c commit b246e56

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

‎pr-checks/changenotes.mts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { pathToFileURL } from "node:url";
66
import { parseArgs } from "node:util";
77
import path from "path";
88

9+
import { ExitCode } from "@actions/core";
910
import { matter } from "lite-matter";
1011

1112
import {
@@ -23,11 +24,11 @@ if (entryPoint && import.meta.url === pathToFileURL(entryPoint).href) {
2324
process.exit(main());
2425
} catch (error) {
2526
console.error(error);
26-
process.exit(1);
27+
process.exit(ExitCode.Failure);
2728
}
2829
}
2930

30-
function main(): number {
31+
function main(): ExitCode {
3132
const { positionals } = parseArgs({
3233
allowPositionals: true,
3334
strict: true,
@@ -43,20 +44,20 @@ function main(): number {
4344
return validate();
4445
default:
4546
console.error(`Unknown command: ${command}`);
46-
return 1;
47+
return ExitCode.Failure;
4748
}
4849
}
4950

50-
function usage(): number {
51+
function usage(): ExitCode {
5152
const message =
5253
"Usage: changenotes.mts flush\n" +
5354
" changenotes.mts validate\n" +
5455
" changenotes.mts help";
5556
console.log(message);
56-
return 0;
57+
return ExitCode.Success;
5758
}
5859

59-
function flush(): number {
60+
function flush(): ExitCode {
6061
try {
6162
// Get the file paths to our changenotes; these will be useful later.
6263
const changenotePaths = fs
@@ -82,25 +83,25 @@ function flush(): number {
8283
fs.unlinkSync(p);
8384
}
8485

85-
return 0;
86+
return ExitCode.Success;
8687
} catch (e) {
8788
console.error("Failed to flush changenotes to 'CHANGELOG.md'", e);
8889
}
8990

90-
return 1;
91+
return ExitCode.Failure;
9192
}
9293

93-
function validate(): number {
94+
function validate(): ExitCode {
9495
try {
9596
if (isValidAllChangenoteFiles(fs.readdirSync(CHANGENOTES_DIR))) {
9697
console.log(`All changenotes in '${CHANGENOTES_DIR}' are valid.`);
97-
return 0;
98+
return ExitCode.Success;
9899
}
99100
} catch (error) {
100101
console.error(
101102
`Failed to read changenotes directory '${CHANGENOTES_DIR}'`,
102103
error,
103104
);
104105
}
105-
return 1;
106+
return ExitCode.Failure;
106107
}

0 commit comments

Comments
 (0)