fix: use the right pkg manager for building git-hosted deps (#7852)

close #7850
This commit is contained in:
Zoltan Kochan
2024-04-03 12:28:26 +02:00
committed by GitHub
parent a5a5082196
commit 167ac4d2b5
2 changed files with 14 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/prepare-package": patch
"pnpm": patch
---
When building git-hosted dependencies, use the package manager required by the project [#7850](https://github.com/pnpm/pnpm/issues/7850).

View File

@@ -46,8 +46,15 @@ export async function preparePackage (opts: PreparePackageOptions, gitRootDir: s
await runLifecycleHook(installScriptName, manifest, execOpts)
for (const scriptName of PREPUBLISH_SCRIPTS) {
if (manifest.scripts[scriptName] == null || manifest.scripts[scriptName] === '') continue
let newScriptName
if (pm !== 'pnpm') {
newScriptName = `${pm}-run-${scriptName}`
manifest.scripts[newScriptName] = `${pm} run ${scriptName}`
} else {
newScriptName = scriptName
}
// eslint-disable-next-line no-await-in-loop
await runLifecycleHook(scriptName, manifest, execOpts)
await runLifecycleHook(newScriptName, manifest, execOpts)
}
} catch (err: unknown) {
assert(util.types.isNativeError(err))