mirror of
https://github.com/pnpm/action-setup.git
synced 2024-11-13 21:33:57 +00:00
Add pnpm install
This commit is contained in:
parent
9a1617cf46
commit
1790ca7f76
BIN
dist/index.js
vendored
BIN
dist/index.js
vendored
Binary file not shown.
@ -2,12 +2,14 @@ import { setFailed } from '@actions/core'
|
|||||||
import getInputs from './inputs'
|
import getInputs from './inputs'
|
||||||
import setOutputs from './outputs'
|
import setOutputs from './outputs'
|
||||||
import installPnpm from './install-pnpm'
|
import installPnpm from './install-pnpm'
|
||||||
|
import pnpmInstall from './pnpm-install'
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
await installPnpm(inputs)
|
await installPnpm(inputs)
|
||||||
console.log('Installation Completed!')
|
console.log('Installation Completed!')
|
||||||
setOutputs(inputs)
|
setOutputs(inputs)
|
||||||
|
pnpmInstall(inputs)
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(error => {
|
main().catch(error => {
|
||||||
|
40
src/pnpm-install/index.ts
Normal file
40
src/pnpm-install/index.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import process from 'process'
|
||||||
|
import path from 'path'
|
||||||
|
import { spawnSync } from 'child_process'
|
||||||
|
import { setFailed } from '@actions/core'
|
||||||
|
import { Inputs } from '../inputs'
|
||||||
|
|
||||||
|
export function runPnpmInstall(inputs: Inputs) {
|
||||||
|
const env = {
|
||||||
|
...process.env,
|
||||||
|
PATH: inputs.binDest + path.delimiter + process.env.PATH
|
||||||
|
}
|
||||||
|
|
||||||
|
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(' ')
|
||||||
|
console.log('Running', cmdStr)
|
||||||
|
|
||||||
|
const { error, status } = spawnSync('pnpm', args, {
|
||||||
|
stdio: 'inherit',
|
||||||
|
cwd: options.cwd,
|
||||||
|
shell: true,
|
||||||
|
env,
|
||||||
|
})
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
setFailed(error)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
setFailed(`Command ${cmdStr} (cwd: ${options.cwd}) exits with status ${status}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default runPnpmInstall
|
Loading…
Reference in New Issue
Block a user