Skip to content

Commit

Permalink
fix(publish): ensure that error code is valid (#3748)
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Jun 26, 2023
1 parent b41afab commit c59b45b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion libs/commands/publish/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,14 @@ class PublishCommand extends Command {

// avoid dumping logs, this isn't a lerna problem
err.name = "ValidationError";

// ensure process exits non-zero
process.exitCode = "errno" in err ? err.errno : 1;
if ("errno" in err && typeof err.errno === "number" && Number.isFinite(err.errno)) {
process.exitCode = err.errno;
} else {
this.logger.error("", `errno "${err.errno}" is not a valid exit code - exiting with code 1`);
process.exitCode = 1;
}

throw err;
});
Expand Down

0 comments on commit c59b45b

Please sign in to comment.