2019-01-12 03:33:27 +00:00
|
|
|
'use strict';
|
2018-03-18 11:59:38 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
const getRunCmdEnv = require('./utils/getRunCmdEnv');
|
2018-03-18 11:59:38 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
function runCmd(cmd, _args, fn) {
|
|
|
|
const args = _args || [];
|
2018-03-18 11:59:38 +00:00
|
|
|
const runner = require('child_process').spawn(cmd, args, {
|
|
|
|
// keep color
|
|
|
|
stdio: 'inherit',
|
|
|
|
env: getRunCmdEnv(),
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-03-18 11:59:38 +00:00
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
runner.on('close', code => {
|
2018-03-18 11:59:38 +00:00
|
|
|
if (fn) {
|
2019-01-12 03:33:27 +00:00
|
|
|
fn(code);
|
2018-03-18 11:59:38 +00:00
|
|
|
}
|
2019-01-12 03:33:27 +00:00
|
|
|
});
|
2018-03-18 11:59:38 +00:00
|
|
|
}
|
|
|
|
|
2019-01-12 03:33:27 +00:00
|
|
|
module.exports = runCmd;
|