fix(core): fix postinstall when nx is not resolveable (#26433)

<!-- 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` -->

## Current Behavior
<!-- This is the behavior we have today -->

`postinstall` task exits 1 when errors are thrown.

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

`postinstall` task always exits 0. Errors are OK because nothing here is
critical.

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes https://github.com/nrwl/nx/issues/26400
This commit is contained in:
Jason Jean 2024-06-06 15:52:56 -04:00 committed by GitHub
parent 795bec023b
commit e44199142d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,6 @@ import { logger } from '../src/utils/logger';
(async () => {
const start = new Date();
let errored = false;
try {
setupWorkspaceContext(workspaceRoot);
if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) {
@ -39,7 +38,6 @@ import { logger } from '../src/utils/logger';
);
}
} catch (e) {
errored = true;
logger.verbose(e);
} finally {
const end = new Date();
@ -47,7 +45,7 @@ import { logger } from '../src/utils/logger';
`Nx postinstall steps took ${end.getTime() - start.getTime()}ms`
);
process.exit(errored ? 1 : 0);
process.exit(0);
}
})();