Skip to content

Commit 6c96cbb

Browse files
refactor: update error handling to use process.exitCode instead of process.exit
1 parent e63aa4b commit 6c96cbb

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

scripts/get-modules.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ function logErrorDetails(error: unknown, { scope }: { scope: string }) {
146146
function installGlobalErrorHandlers() {
147147
process.on("unhandledRejection", (reason) => {
148148
logErrorDetails(reason, { scope: "Unhandled promise rejection" });
149-
process.exit(1);
149+
process.exitCode = 1;
150150
});
151151

152152
process.on("uncaughtException", (error) => {
153153
logErrorDetails(error, { scope: "Uncaught exception" });
154-
process.exit(1);
154+
process.exitCode = 1;
155155
});
156156
}
157157

@@ -588,14 +588,12 @@ async function processModules() {
588588
}
589589

590590
async function main() {
591-
try {
592-
await rotateModulesDirectory();
593-
await processModules();
594-
} catch (error) {
595-
logger.error("Stage 'get-modules' failed");
596-
logErrorDetails(error, { scope: "Fatal error" });
597-
process.exit(1);
598-
}
591+
await rotateModulesDirectory();
592+
await processModules();
599593
}
600594

601-
await main();
595+
main().catch((error) => {
596+
logger.error("Stage 'get-modules' failed");
597+
logErrorDetails(error, { scope: "Fatal error" });
598+
process.exitCode = 1;
599+
});

0 commit comments

Comments
 (0)