Skip to content

Commit

Permalink
fix(publish): ensure that error code is a number (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed Jun 28, 2023
1 parent 9b6a400 commit 0b823d5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/publish/src/publish-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,12 @@ export class PublishCommand extends Command<PublishCommandOption> {
// 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 0b823d5

Please sign in to comment.