-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
index.ts
38 lines (30 loc) · 914 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { setFailed, startGroup, endGroup } from '@actions/core'
import { spawnSync } from 'child_process'
import { Inputs } from '../inputs'
import { patchPnpmEnv } from '../utils'
export function runPnpmInstall(inputs: Inputs) {
const env = patchPnpmEnv(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}...`)
const { error, status } = spawnSync('pnpm', args, {
stdio: 'inherit',
cwd: options.cwd,
shell: true,
env,
})
endGroup()
if (error) {
setFailed(error)
continue
}
if (status) {
setFailed(`Command ${cmdStr} (cwd: ${options.cwd}) exits with status ${status}`)
continue
}
}
}
export default runPnpmInstall