Skip to content

Commit

Permalink
fix(cli): ensure terminating due to an empty event loop counts as an …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
merceyz committed Jul 17, 2024
1 parent 35167b2 commit ec4396e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
23 changes: 23 additions & 0 deletions .yarn/versions/3a4fece1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
releases:
"@yarnpkg/cli": patch

declined:
- "@yarnpkg/plugin-compat"
- "@yarnpkg/plugin-constraints"
- "@yarnpkg/plugin-dlx"
- "@yarnpkg/plugin-essentials"
- "@yarnpkg/plugin-init"
- "@yarnpkg/plugin-interactive-tools"
- "@yarnpkg/plugin-nm"
- "@yarnpkg/plugin-npm-cli"
- "@yarnpkg/plugin-pack"
- "@yarnpkg/plugin-patch"
- "@yarnpkg/plugin-pnp"
- "@yarnpkg/plugin-pnpm"
- "@yarnpkg/plugin-stage"
- "@yarnpkg/plugin-typescript"
- "@yarnpkg/plugin-version"
- "@yarnpkg/plugin-workspace-tools"
- "@yarnpkg/builder"
- "@yarnpkg/core"
- "@yarnpkg/doctor"
5 changes: 5 additions & 0 deletions packages/yarnpkg-cli/sources/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ export async function runExit(argv: Array<string>, {cwd = ppath.cwd(), selfPath,
const cli = getBaseCli({cwd, pluginConfiguration});

try {
// The exit code is set to an error code before the CLI runs so that
// when the event loop becomes empty and node terminates without
// finishing this function call it counts as an error.
// https://github.com/yarnpkg/berry/issues/6398
process.exitCode = 42;
process.exitCode = await run(cli, argv, {selfPath, pluginConfiguration});
} catch (error) {
Cli.defaultContext.stdout.write(cli.error(error));
Expand Down

0 comments on commit ec4396e

Please sign in to comment.