2019-03-01 21:52:01 +00:00
|
|
|
|
var spawn = require('child_process').spawn;
|
|
|
|
|
|
|
|
|
|
function exec(cmd) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
2019-03-03 22:51:52 +00:00
|
|
|
|
const command = spawn(cmd, {shell: true, env: process.env});
|
2019-03-01 21:52:01 +00:00
|
|
|
|
command.stdout.pipe(process.stdout);
|
|
|
|
|
command.stderr.pipe(process.stderr);
|
|
|
|
|
command.on('exit', function(statusCode) {
|
|
|
|
|
if (statusCode != 0) {
|
2019-03-03 22:51:52 +00:00
|
|
|
|
reject(new Error('Command \'' + cmd + '\' has exited with status ' + statusCode + '.'));
|
2019-03-01 21:52:01 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
resolve();
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module.exports = { exec }
|