diff --git a/src/cli/commands/run.js b/src/cli/commands/run.js index ccc7915df1..d8e55721f6 100644 --- a/src/cli/commands/run.js +++ b/src/cli/commands/run.js @@ -36,14 +36,15 @@ export async function getBinEntries(config: Config): Promise // Same thing, but for the pnp dependencies, located inside the cache if (await fs.exists(`${config.lockfileFolder}/${constants.PNP_FILENAME}`)) { const pnpApi = dynamicRequire(`${config.lockfileFolder}/${constants.PNP_FILENAME}`); - const topLevelInformation = pnpApi.getPackageInformation({name: null, reference: null}); - for (const [name, reference] of topLevelInformation.packageDependencies.entries()) { + const packageLocator = pnpApi.getPackageLocator(`${config.cwd}/`); + const packageInformation = pnpApi.getPackageInformation(packageLocator); + + for (const [name, reference] of packageInformation.packageDependencies.entries()) { const dependencyInformation = pnpApi.getPackageInformation({name, reference}); if (dependencyInformation.packageLocation) { - const fullPath = path.resolve(config.lockfileFolder, dependencyInformation.packageLocation); - binFolders.add(`${fullPath}/.bin`); + binFolders.add(`${dependencyInformation.packageLocation}/.bin`); } } } diff --git a/src/util/execute-lifecycle-script.js b/src/util/execute-lifecycle-script.js index 31d7dd3be4..0d2dfe4dc1 100644 --- a/src/util/execute-lifecycle-script.js +++ b/src/util/execute-lifecycle-script.js @@ -212,15 +212,13 @@ export async function makeEnv( } } - // Otherwise, only add the top-level dependencies to the PATH - // Note that this isn't enough when executing scripts from subdependencies, but since dependencies with postinstall - // scripts have other issues that require us to make them fallback to regular node_modules installation (like sharing - // artifacts), we can sit on this one until we fix everything at once. if (await fs.exists(`${config.lockfileFolder}/${constants.PNP_FILENAME}`)) { const pnpApi = dynamicRequire(`${config.lockfileFolder}/${constants.PNP_FILENAME}`); - const topLevelInformation = pnpApi.getPackageInformation({name: null, reference: null}); - for (const [name, reference] of topLevelInformation.packageDependencies.entries()) { + const packageLocator = pnpApi.getPackageLocator(`${config.cwd}/`); + const packageInformation = pnpApi.getPackageInformation(packageLocator); + + for (const [name, reference] of packageInformation.packageDependencies.entries()) { const dependencyInformation = pnpApi.getPackageInformation({name, reference}); if (!dependencyInformation || !dependencyInformation.packageLocation) {