From 4960c7c6744e20bbeb36b2ece6406425abd33f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Moreno?= Date: Mon, 20 Apr 2020 13:52:52 +0200 Subject: [PATCH] use spawn instead of exec --- src/package.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/package.ts b/src/package.ts index b57c918f..42b1278c 100644 --- a/src/package.ts +++ b/src/package.ts @@ -20,7 +20,6 @@ import { getDependencies } from './npm'; const readFile = denodeify(fs.readFile); const unlink = denodeify(fs.unlink as any); const stat = denodeify(fs.stat); -const exec = denodeify(cp.exec as any, (error, stdout, stderr) => [undefined, { stdout, stderr, error }]); const glob = denodeify(_glob); const resourcesPath = path.join(path.dirname(__dirname), 'resources'); @@ -929,11 +928,12 @@ async function prepublish(cwd: string, manifest: Manifest, useYarn: boolean = fa console.log(`Executing prepublish script '${useYarn ? 'yarn' : 'npm'} run vscode:prepublish'...`); - const { stdout, stderr, error } = await exec(`${useYarn ? 'yarn' : 'npm'} run vscode:prepublish`, { cwd, maxBuffer: 5000 * 1024 }); - process.stdout.write(stdout); - // in case of error, stderr gets written by a top-level exception handler - if (error !== undefined) throw error; - process.stderr.write(stderr); + await new Promise((c, e) => { + const tool = useYarn ? 'yarn' : 'npm'; + const child = cp.spawn(tool, ['run', 'vscode:prepublish'], { cwd, shell: true, stdio: 'inherit' }); + child.on('exit', code => code === 0 ? c() : e(`${tool} failed with exit code ${code}`)); + child.on('error', e); + }); } async function getPackagePath(cwd: string, manifest: Manifest, options: IPackageOptions = {}): Promise {