Complete basic

This commit is contained in:
khai96_ 2020-05-08 13:06:16 +07:00
parent 21f3fd8b57
commit 7d62586afe
3 changed files with 26 additions and 11 deletions
src/install

View file

@ -1,17 +1,23 @@
import { spawnSync } from 'child_process'
import { spawn } from 'child_process'
import { downloadSelfInstaller } from '../self-installer'
import { Inputs } from '../inputs'
export async function runSelfInstaller(inputs: Inputs) {
return spawnSync('node', {
export function runSelfInstaller(inputs: Inputs): Promise<number> {
const cp = spawn('node', {
env: {
PNPM_VERSION: inputs.version,
PNPM_DEST: inputs.dest,
PNPM_BIN_DEST: inputs.binDest,
PNPM_REGISTRY: inputs.registry,
},
input: await downloadSelfInstaller(),
stdio: 'inherit',
stdio: ['pipe', 'inherit', 'inherit'],
})
downloadSelfInstaller().pipe(cp.stdin)
return new Promise((resolve, reject) => {
cp.on('error', reject)
cp.on('close', resolve)
})
}