Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't override process.exitCode #268

Merged
merged 2 commits into from May 23, 2023

Conversation

merceyz
Copy link
Member

@merceyz merceyz commented May 21, 2023

What's the problem this PR addresses?

  • If the package manager launched by Corepack sets process.exitCode before letting the event loop tick then Corepack will override it.
  • Corepack sets process.exitCode = 0 after successfully launching a package manager which prevents them from defaulting it to an error if they didn't explicitly set it, for example:
const assert = require('assert');

process.once('beforeExit', () => {
	assert(process.exitCode !== undefined, 'CLI should have explicitly set an exitCode');
});

How did you fix it?

Don't change process.exitCode if it's already set and never set it to 0.

@merceyz merceyz changed the title fix: don't override exit codes fix: don't override process.exitCode May 21, 2023
@merceyz merceyz merged commit 17d1f3d into nodejs:main May 23, 2023
10 checks passed
@merceyz merceyz deleted the merceyz/fix/exit-codes branch May 23, 2023 22:32
@merceyz merceyz mentioned this pull request May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants