Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: install dependencies execute preprepare script
  • Loading branch information
btea committed Jan 18, 2025
commit 5bd161fb2640650071d07a89658237e5456622ab
6 changes: 6 additions & 0 deletions .changeset/eighty-lemons-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@pnpm/headless": patch
"@pnpm/core": patch
---

When installing dependencies, execute the preprepare script.
3 changes: 2 additions & 1 deletion pkg-manager/core/src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1266,8 +1266,9 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
...makeNodeRequireOption(path.join(opts.lockfileDir, '.pnp.cjs')),
}
}
console.log('Running preinstall, install, postinstall, preprepare and prepare scripts')
const projectsToBeBuilt = projectsWithTargetDirs.filter(({ mutation }) => mutation === 'install') as ProjectToBeInstalled[]
await runLifecycleHooksConcurrently(['preinstall', 'install', 'postinstall', 'prepare'],
await runLifecycleHooksConcurrently(['preinstall', 'install', 'postinstall', 'preprepare', 'prepare'],
Comment thread
btea marked this conversation as resolved.
Outdated
projectsToBeBuilt,
opts.childConcurrency,
opts.scriptsOpts
Expand Down
3 changes: 2 additions & 1 deletion pkg-manager/core/test/install/lifecycleScripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,12 @@ test('run install scripts in the current project', async () => {
install: `node -e "console.log('install-' + process.cwd())" | ${server.generateSendStdinScript()}`,
postinstall: `node -e "console.log('postinstall-' + process.cwd())" | ${server.generateSendStdinScript()}`,
preinstall: `node -e "console.log('preinstall-' + process.cwd())" | ${server.generateSendStdinScript()}`,
preprepare: `node -e "console.log('preprepare-' + process.cwd())" | ${server.generateSendStdinScript()}`,
},
}, [], testDefaults({ fastUnpack: false }))
await install(manifest, testDefaults({ fastUnpack: false }))

expect(server.getLines()).toStrictEqual([`preinstall-${process.cwd()}`, `install-${process.cwd()}`, `postinstall-${process.cwd()}`])
expect(server.getLines()).toStrictEqual([`preinstall-${process.cwd()}`, `install-${process.cwd()}`, `postinstall-${process.cwd()}`, `preprepare-${process.cwd()}`])
expect(serverForDevPreinstall.getLines()).toStrictEqual([
// The pnpm:devPreinstall script runs twice in this test. Once for the
// initial "addDependenciesToPackage" test setup stage and again for the
Expand Down
2 changes: 1 addition & 1 deletion pkg-manager/headless/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ export async function headlessInstall (opts: HeadlessOptions): Promise<Installat

if (!opts.ignoreScripts && !opts.ignorePackageManifest) {
await runLifecycleHooksConcurrently(
['preinstall', 'install', 'postinstall', 'prepare'],
['preinstall', 'install', 'postinstall', 'preprepare', 'prepare'],
projectsToBeBuilt,
opts.childConcurrency ?? 5,
scriptsOpts
Expand Down