fix(core): do not run postinstall unless it is the main nx package (#12591)

This commit is contained in:
Jason Jean 2022-10-13 20:41:07 -04:00 committed by GitHub
parent 773c0cb6c1
commit 0961cb34d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,7 +6,7 @@ import { daemonClient } from '../src/daemon/client/client';
(async () => {
try {
if (fileExists(join(workspaceRoot, 'nx.json'))) {
if (isMainNxPackage() && fileExists(join(workspaceRoot, 'nx.json'))) {
try {
await daemonClient.stop();
} catch (e) {}
@ -27,3 +27,11 @@ import { daemonClient } from '../src/daemon/client/client';
}
}
})();
function isMainNxPackage() {
const mainNxPath = require.resolve('nx', {
paths: [workspaceRoot],
});
const thisNxPath = require.resolve('nx');
return mainNxPath === thisNxPath;
}