fix corepack detection for package manager version determination (#11596)

The previous logic was checking for the env var `ENABLE_EXPERIMENTAL_COREPACK` to determine if corepack was being used by a project. However, this value only means that the build system should consider corepack, not that it's actively being used.

We need to check that flag AND the existence of a `packageManager` property in the project's `package.json`.
This commit is contained in:
Sean Massa
2024-05-15 14:25:01 -05:00
committed by GitHub
parent 41c44d6594
commit ccd7eb1fb7
9 changed files with 95 additions and 23 deletions

View File

@@ -482,11 +482,15 @@ export const build: BuildV2 = async ({
spawnOpts.env.CI = 'false';
}
const { cliType, lockfileVersion } = await scanParentDirs(entrypointDir);
const { cliType, lockfileVersion, packageJson } = await scanParentDirs(
entrypointDir,
true
);
spawnOpts.env = getEnvForPackageManager({
cliType,
lockfileVersion,
packageJsonPackageManager: packageJson?.packageManager,
nodeVersion,
env: spawnOpts.env || {},
});