fix: preinstall should run after dependencies are installed (#3395)

This commit is contained in:
Zoltan Kochan
2021-04-26 19:06:41 +03:00
committed by GitHub
parent a0894631d0
commit 3e3c3ff714
3 changed files with 8 additions and 19 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/headless": patch
"supi": patch
---
`preinstall` scripts should run after installing the dependencies (this is how it works with npm).

View File

@@ -164,15 +164,6 @@ export default async (opts: HeadlessOptions) => {
unsafePerm: opts.unsafePerm || false,
}
if (!opts.ignoreScripts && !opts.ignorePackageManifest) {
await runLifecycleHooksConcurrently(
['preinstall'],
opts.projects,
opts.childConcurrency ?? 5,
scriptsOpts
)
}
const skipped = opts.skipped || new Set<string>()
if (currentLockfile != null && !opts.ignorePackageManifest) {
await prune(
@@ -434,7 +425,7 @@ export default async (opts: HeadlessOptions) => {
if (!opts.ignoreScripts && !opts.ignorePackageManifest) {
await runLifecycleHooksConcurrently(
['install', 'postinstall', 'prepublish', 'prepare'],
['preinstall', 'install', 'postinstall', 'prepublish', 'prepare'],
opts.projects,
opts.childConcurrency ?? 5,
scriptsOpts

View File

@@ -304,14 +304,6 @@ export async function mutateModules (
stdio: opts.ownLifecycleHooksStdio,
unsafePerm: opts.unsafePerm || false,
}
if (!opts.ignoreScripts) {
await runLifecycleHooksConcurrently(
['preinstall'],
projectsToBeInstalled,
opts.childConcurrency,
scriptsOpts
)
}
// TODO: make it concurrent
for (const project of ctx.projects) {
@@ -467,7 +459,7 @@ export async function mutateModules (
if (opts.enablePnp) {
scriptsOpts.extraEnv = makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs'))
}
await runLifecycleHooksConcurrently(['install', 'postinstall', 'prepare'],
await runLifecycleHooksConcurrently(['preinstall', 'install', 'postinstall', 'prepare'],
projectsToBeInstalled,
opts.childConcurrency,
scriptsOpts