Skip to content

Commit 4960c7c

Browse files
committed
use spawn instead of exec
1 parent dc36c1f commit 4960c7c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/package.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import { getDependencies } from './npm';
2020
const readFile = denodeify<string, string, string>(fs.readFile);
2121
const unlink = denodeify<string, void>(fs.unlink as any);
2222
const stat = denodeify(fs.stat);
23-
const exec = denodeify<string, { cwd?: string; env?: any; maxBuffer?: number; }, { stdout: string; stderr: string; error: any }>(cp.exec as any, (error, stdout, stderr) => [undefined, { stdout, stderr, error }]);
2423
const glob = denodeify<string, _glob.IOptions, string[]>(_glob);
2524

2625
const resourcesPath = path.join(path.dirname(__dirname), 'resources');
@@ -929,11 +928,12 @@ async function prepublish(cwd: string, manifest: Manifest, useYarn: boolean = fa
929928

930929
console.log(`Executing prepublish script '${useYarn ? 'yarn' : 'npm'} run vscode:prepublish'...`);
931930

932-
const { stdout, stderr, error } = await exec(`${useYarn ? 'yarn' : 'npm'} run vscode:prepublish`, { cwd, maxBuffer: 5000 * 1024 });
933-
process.stdout.write(stdout);
934-
// in case of error, stderr gets written by a top-level exception handler
935-
if (error !== undefined) throw error;
936-
process.stderr.write(stderr);
931+
await new Promise((c, e) => {
932+
const tool = useYarn ? 'yarn' : 'npm';
933+
const child = cp.spawn(tool, ['run', 'vscode:prepublish'], { cwd, shell: true, stdio: 'inherit' });
934+
child.on('exit', code => code === 0 ? c() : e(`${tool} failed with exit code ${code}`));
935+
child.on('error', e);
936+
});
937937
}
938938

939939
async function getPackagePath(cwd: string, manifest: Manifest, options: IPackageOptions = {}): Promise<string> {

0 commit comments

Comments
 (0)