mirror of
https://github.com/pnpm/action-setup.git
synced 2026-06-17 15:53:45 +08:00
`patchPnpmEnv` prepended `dest/node_modules/.bin` to PATH before
spawning `pnpm install` / `pnpm store prune`. On Windows in standalone
mode, `.bin/pnpm.cmd` is an npm-created shim that always points at the
BOOTSTRAP pnpm (currently 11.0.4) — the binary npm linked when it
installed `@pnpm/exe` into `node_modules`. The self-updated pnpm
written by `pnpm self-update` lives at `$PNPM_HOME/bin`, which is
separately added to PATH via `addPath()` in install-pnpm.
When the user requested a pnpm version different from the bootstrap
under `standalone: true` on Windows, patchPnpmEnv's `.bin` entry
shadowed the self-updated `$PNPM_HOME/bin` and the action's internal
`pnpm install` ran on the bootstrap. On a pnpm 11.0.x bootstrap this
broke any 11.1+ install flag (e.g. `--no-runtime`), reporting:
ERROR Unknown option: 'runtime'
POSIX standalone got lucky because `.bin` and `$PNPM_HOME` resolve to
the same directory there. Non-standalone never tripped on this since
the `.bin/pnpm` symlink for a regular `pnpm` package keeps working
across self-updates.
Removed `patchPnpmEnv` and the now-empty `src/utils/` module.
`spawnSync` now inherits `process.env`, whose PATH is already
correctly fronted by `$PNPM_HOME/bin` and `$PNPM_HOME` via the
`addPath` calls in install-pnpm.
Added `standalone_windows_self_update` to test.yaml as a regression
guard: standalone on Windows + target 11.1.0 + `run_install` with
`--no-runtime`. With the previous code, the install would have run
under the bootstrap (11.0.4) and errored on the unknown flag.
Originally found while building pnpm/setup (the new combined
pnpm + runtime action).
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { setFailed, startGroup, endGroup } from '@actions/core'
|
|
import { spawnSync } from 'child_process'
|
|
import { Inputs } from '../inputs'
|
|
|
|
export function runPnpmInstall(inputs: Inputs) {
|
|
for (const options of inputs.runInstall) {
|
|
const args = ['install']
|
|
if (options.recursive) args.unshift('recursive')
|
|
if (options.args) args.push(...options.args)
|
|
|
|
const cmdStr = ['pnpm', ...args].join(' ')
|
|
startGroup(`Running ${cmdStr}...`)
|
|
|
|
// spawnSync inherits process.env, which already has $PNPM_HOME/bin and
|
|
// $PNPM_HOME prepended via addPath() in install-pnpm. Do NOT pass a
|
|
// hand-patched env that adds node_modules/.bin to the front — on
|
|
// Windows standalone, .bin/pnpm.cmd is an npm shim pointing at the
|
|
// BOOTSTRAP pnpm, which would shadow the self-updated one and break
|
|
// newer-pnpm-only behavior.
|
|
const { error, status } = spawnSync('pnpm', args, {
|
|
stdio: 'inherit',
|
|
cwd: options.cwd,
|
|
shell: true,
|
|
})
|
|
|
|
endGroup()
|
|
|
|
if (error) {
|
|
setFailed(error)
|
|
continue
|
|
}
|
|
|
|
if (status) {
|
|
setFailed(`Command ${cmdStr} (cwd: ${options.cwd}) exits with status ${status}`)
|
|
continue
|
|
}
|
|
}
|
|
}
|
|
|
|
export default runPnpmInstall
|