2020-05-09 21:50:47 +07:00
|
|
|
import { setFailed, startGroup, endGroup } from '@actions/core'
|
2022-02-23 10:07:15 +07:00
|
|
|
import { spawnSync } from 'child_process'
|
2020-05-09 20:24:52 +07:00
|
|
|
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(' ')
|
2020-05-09 21:50:47 +07:00
|
|
|
startGroup(`Running ${cmdStr}...`)
|
2020-05-09 20:24:52 +07:00
|
|
|
|
2026-05-11 22:48:51 +02:00
|
|
|
// 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.
|
2020-05-09 20:24:52 +07:00
|
|
|
const { error, status } = spawnSync('pnpm', args, {
|
|
|
|
|
stdio: 'inherit',
|
|
|
|
|
cwd: options.cwd,
|
|
|
|
|
shell: true,
|
|
|
|
|
})
|
|
|
|
|
|
2020-05-09 21:50:47 +07:00
|
|
|
endGroup()
|
|
|
|
|
|
2020-05-09 20:24:52 +07:00
|
|
|
if (error) {
|
|
|
|
|
setFailed(error)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (status) {
|
|
|
|
|
setFailed(`Command ${cmdStr} (cwd: ${options.cwd}) exits with status ${status}`)
|
|
|
|
|
continue
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default runPnpmInstall
|