Skip to content

Commit

Permalink
fix(js): change verdaccio childProcess kill order (#28364)
Browse files Browse the repository at this point in the history
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->

## Current Behavior
`@nx/js:verdaccio` current call `npm config` to setup npm scopes in
global `.npmrc` file, which it's supposed to do.

However, when process is killed (using terminal exit command or any
other way), the process is killed and doesn't restore changed config.

In my case I'm changing scope to my private scope (using `scopes`
option), but after kill I need to restore manually.

## Expected Behavior
When process be killed, restore all configs that was set.

## Related Issue(s)
#28353

Fixes #28353
  • Loading branch information
alancpazetto authored and jaysoo committed Oct 17, 2024
1 parent 84ed1d7 commit c41de4b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/js/src/executors/verdaccio/verdaccio.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ export async function verdaccioExecutor(
options.location === 'none' ? [] : [setupNpm(options), setupYarn(options)];

const processExitListener = (signal?: number | NodeJS.Signals) => {
if (childProcess) {
childProcess.kill(signal);
}
for (const fn of cleanupFunctions) {
fn();
}
if (childProcess) {
childProcess.kill(signal);
}
};
process.on('exit', processExitListener);
process.on('SIGTERM', processExitListener);
Expand Down

0 comments on commit c41de4b

Please sign in to comment.