fix: run setup.js after self-update to create pn/pnx hardlinks

self-update replaces the @pnpm/exe package files but does not re-run
preinstall scripts. This leaves pn/pnpx/pnx as placeholder files
("This file intentionally left blank") instead of hardlinks to the
actual binary. Run setup.js explicitly after self-update to fix this.
This commit is contained in:
Zoltan Kochan
2026-03-26 18:49:59 +01:00
parent 11687bb3d2
commit 51e56d41e9
2 changed files with 130 additions and 119 deletions

236
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -59,9 +59,20 @@ export async function runSelfInstaller(inputs: Inputs): Promise<number> {
if (exitCode !== 0) {
return exitCode
}
// self-update replaces package files but does not re-run preinstall
// scripts, so setup.js (which hardlinks pn/pnpx/pnx to the binary)
// needs to be run explicitly.
if (standalone) {
const exeDir = path.join(dest, 'node_modules', '@pnpm', 'exe')
const setupScript = path.join(exeDir, 'setup.js')
if (existsSync(setupScript)) {
await runCommand(process.execPath, [setupScript], { cwd: exeDir })
}
}
}
// Create pn/pnx alias symlinks if the installed version supports them
// Create pn/pnx alias bin links if the installed version supports them
// (pnpm v11+ adds pn and pnx as short aliases)
await ensureAliasLinks(pnpmHome, standalone)