Skip to content

Commit b1783e0

Browse files
committed
Improve the safety around unefined exit codes.
1 parent 20bf52c commit b1783e0

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

apps/rush-lib/src/cli/RushCommandLineParser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ export class RushCommandLineParser extends CommandLineParser {
355355
// performs nontrivial work that can throw an exception. Either the Rush class would need
356356
// to handle reporting for those exceptions, or else _populateActions() should be moved
357357
// to a RushCommandLineParser lifecycle stage that can handle it.
358-
if (process.exitCode! > 0) {
358+
if (!process.exitCode || process.exitCode > 0) {
359359
process.exit(process.exitCode);
360360
} else {
361361
process.exit(1);

apps/rush-lib/src/scripts/install-run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,11 @@ export function installAndRun(
433433
}
434434
);
435435

436-
return result.status || 1; // If result.status is null, the process was terminated from a signal
436+
if (result.status) {
437+
return result.status;
438+
} else {
439+
throw result.error || new Error('An unknown error occurred.');
440+
}
437441
}
438442

439443
export function runWithErrorAndStatusCode(fn: () => number): void {

0 commit comments

Comments
 (0)