action-setup/src/install/run.ts

26 lines
655 B
TypeScript
Raw Normal View History

2020-05-08 13:06:16 +07:00
import { spawn } from 'child_process'
2020-05-08 13:47:46 +07:00
import { execPath } from 'process'
2020-05-08 11:29:39 +07:00
import { downloadSelfInstaller } from '../self-installer'
import { Inputs } from '../inputs'
2020-05-08 13:06:16 +07:00
export function runSelfInstaller(inputs: Inputs): Promise<number> {
2020-05-08 13:47:46 +07:00
const cp = spawn(execPath, {
2020-05-08 11:29:39 +07:00
env: {
PNPM_VERSION: inputs.version,
PNPM_DEST: inputs.dest,
PNPM_BIN_DEST: inputs.binDest,
PNPM_REGISTRY: inputs.registry,
},
2020-05-08 13:06:16 +07:00
stdio: ['pipe', 'inherit', 'inherit'],
})
downloadSelfInstaller().pipe(cp.stdin)
return new Promise((resolve, reject) => {
cp.on('error', reject)
cp.on('close', resolve)
2020-05-08 11:29:39 +07:00
})
}
export default runSelfInstaller