reimplemented promised spawn
This commit is contained in:
parent
26e597a458
commit
2349363917
@ -16,7 +16,7 @@ const nodeRepo = 'https://github.com/nodejs/node';
|
||||
async function gitClone () {
|
||||
const args = [ 'clone', '--progress', nodeRepo, 'node' ];
|
||||
const promise = spawn('git', args, { cwd: buildPath });
|
||||
const child = promise.childProcess;
|
||||
const { child } = promise;
|
||||
|
||||
const gauge = log.newItem('', 100);
|
||||
gauge.enableProgress();
|
||||
|
||||
15
lib/spawn.js
15
lib/spawn.js
@ -1,5 +1,14 @@
|
||||
import chipo from 'child-process-promise';
|
||||
import chipo from 'child_process';
|
||||
|
||||
export function spawn (...args) {
|
||||
return chipo.spawn(...args);
|
||||
export function spawn (cmd, args, opts) {
|
||||
const child = chipo.spawn(cmd, args, opts);
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
child.on('error', reject);
|
||||
child.on('close', function (code) {
|
||||
if (code) return reject(new Error(`${cmd} failed with code ${code}`));
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
promise.child = child;
|
||||
return promise;
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@
|
||||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"child-process-promise": "2.0.3",
|
||||
"expand-template": "1.0.2",
|
||||
"fs-promise": "0.5.0",
|
||||
"minimist": "1.2.0",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user