Use node-fetch

This commit is contained in:
khai96_
2020-05-08 21:34:25 +07:00
parent 738fb9213f
commit 9979c3d928
5 changed files with 41 additions and 744 deletions

View File

@ -3,7 +3,7 @@ import { execPath } from 'process'
import { downloadSelfInstaller } from '../self-installer'
import { Inputs } from '../inputs'
export function runSelfInstaller(inputs: Inputs): Promise<number> {
export async function runSelfInstaller(inputs: Inputs): Promise<number> {
const cp = spawn(execPath, {
env: {
PNPM_VERSION: inputs.version,
@ -14,7 +14,8 @@ export function runSelfInstaller(inputs: Inputs): Promise<number> {
stdio: ['pipe', 'inherit', 'inherit'],
})
downloadSelfInstaller().pipe(cp.stdin)
const response = await downloadSelfInstaller()
response.body.pipe(cp.stdin)
return new Promise((resolve, reject) => {
cp.on('error', reject)