diff --git a/.changeset/soft-peaches-boil.md b/.changeset/soft-peaches-boil.md new file mode 100644 index 00000000000..9589c92a0ea --- /dev/null +++ b/.changeset/soft-peaches-boil.md @@ -0,0 +1,6 @@ +--- +"@pnpm/lifecycle": patch +"pnpm": patch +--- + +Don't relink injected directories if they were not built. diff --git a/exec/lifecycle/src/runLifecycleHooksConcurrently.ts b/exec/lifecycle/src/runLifecycleHooksConcurrently.ts index 23e6c811425..6d1220166fe 100644 --- a/exec/lifecycle/src/runLifecycleHooksConcurrently.ts +++ b/exec/lifecycle/src/runLifecycleHooksConcurrently.ts @@ -49,11 +49,13 @@ export async function runLifecycleHooksConcurrently ( pkgRoot: rootDir, rootModulesDir: modulesDir, } + let isBuilt = false for (const stage of (importerStages ?? stages)) { if ((manifest.scripts == null) || !manifest.scripts[stage]) continue await runLifecycleHook(stage, manifest, runLifecycleHookOpts) + isBuilt = true } - if (targetDirs == null || targetDirs.length === 0) return + if (targetDirs == null || targetDirs.length === 0 || !isBuilt) return const filesResponse = await fetchFromDir(rootDir, { resolveSymlinks: opts.resolveSymlinksInInjectedDirs }) await Promise.all( targetDirs.map(async (targetDir) => {