mirror of
https://github.com/pnpm/action-setup.git
synced 2026-05-08 01:48:28 +00:00
`pnpm self-update <version>` writes the target binary to
`${PNPM_HOME}/bin/`, leaving the bootstrap symlink at `${PNPM_HOME}/pnpm`
untouched. The `bin_dest` output was set to `${PNPM_HOME}`, so consumers
invoking `${{ steps.pnpm.outputs.bin_dest }}/pnpm` got the bootstrap
version (currently 11.0.4) instead of the version they requested.
PATH lookup hid the bug: `${PNPM_HOME}/bin` was prepended ahead of
`${PNPM_HOME}`, so `pnpm` resolved from PATH was the right one. Existing
version-respect tests only checked `pnpm --version`, not `bin_dest`.
Resolve `binDest` inside `runSelfInstaller` (target lives in
`${PNPM_HOME}/bin` after self-update, otherwise stays at `${PNPM_HOME}`)
and plumb it through to `setOutputs`. Add a regression test that invokes
`${bin_dest}/pnpm --version` directly across Linux/macOS/Windows.
42 lines
954 B
TypeScript
42 lines
954 B
TypeScript
import { setFailed, saveState, getState } from '@actions/core'
|
|
import restoreCache from './cache-restore'
|
|
import saveCache from './cache-save'
|
|
import getInputs, { Inputs } from './inputs'
|
|
import installPnpm from './install-pnpm'
|
|
import setOutputs from './outputs'
|
|
import pnpmInstall from './pnpm-install'
|
|
import pruneStore from './pnpm-store-prune'
|
|
|
|
async function main() {
|
|
const inputs = getInputs()
|
|
|
|
if (getState('is_post') === 'true') {
|
|
await runPost(inputs)
|
|
} else {
|
|
await runMain(inputs)
|
|
}
|
|
}
|
|
|
|
async function runMain(inputs: Inputs) {
|
|
saveState('is_post', 'true')
|
|
|
|
const binDest = await installPnpm(inputs)
|
|
if (binDest === undefined) return
|
|
console.log('Installation Completed!')
|
|
setOutputs(inputs, binDest)
|
|
|
|
await restoreCache(inputs)
|
|
|
|
pnpmInstall(inputs)
|
|
}
|
|
|
|
async function runPost(inputs: Inputs) {
|
|
pruneStore(inputs)
|
|
await saveCache(inputs)
|
|
}
|
|
|
|
main().catch(error => {
|
|
console.error(error)
|
|
setFailed(error)
|
|
})
|