ant-design-vue/antd-tools/runCmd.js

21 lines
366 B
JavaScript
Raw Normal View History

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