1
0
mirror of https://github.com/pnpm/action-setup synced 2026-05-13 04:51:06 +02:00

fix: fall back to pnpm shim in same directory for self-update bin/

ensureAliasLinks had a hardcoded relative path to @pnpm/exe/pnpm which
only works from node_modules/.bin/. In self-update's bin/ directory
($PNPM_HOME/bin/), that path doesn't resolve. Now falls back to using
the pnpm shim in the same directory when the package path doesn't exist.
This commit is contained in:
Zoltan Kochan
2026-03-26 20:24:03 +01:00
parent 76bfe9d01c
commit aec59b9f6c
3 changed files with 153 additions and 114 deletions

View File

@@ -125,6 +125,31 @@ describe('ensureAliasLinks', () => {
})
})
describe('self-update bin directory (pnpm shim in same dir)', () => {
it('creates aliases using pnpm shim in the same directory on unix', async () => {
// self-update creates a pnpm shim in $PNPM_HOME/bin/ — no package dir
await writeFile(path.join(binDir, 'pnpm'), '#!/bin/sh\nexec /path/to/real/pnpm "$@"\n', { mode: 0o755 })
await ensureAliasLinks(binDir, true, 'linux')
const pnTarget = await readlink(path.join(binDir, 'pn'))
expect(pnTarget).toBe('pnpm')
const pnxContent = await readFile(path.join(binDir, 'pnx'), 'utf8')
expect(pnxContent).toContain('pnpm')
expect(pnxContent).toContain('dlx')
})
it('creates .cmd shims using pnpm in same dir on windows', async () => {
await writeFile(path.join(binDir, 'pnpm'), 'pnpm binary')
await ensureAliasLinks(binDir, true, 'win32')
const cmdContent = await readFile(path.join(binDir, 'pn.cmd'), 'utf8')
expect(cmdContent).toContain('pnpm')
})
})
describe('overwrites existing broken shims', () => {
it('replaces npm broken shim with symlink on unix', async () => {
await setupStandaloneFixture(binDir)