const { spawn } = require('child_process'); const spawnWin = require('cross-spawn'); module.exports = function exec(command, args, opts) { return new Promise((resolve, reject) => { const child = process.platform === 'win32' ? spawnWin(command, args, Object.assign({ stdio: 'inherit', env: process.env }, opts)) : spawn(command, args, Object.assign({ stdio: 'inherit', env: process.env }, opts)); child.once('error', (err) => { console.log(err); reject(err); }); child.once('close', (code) => { if (code === 1) { process.exit(1); } else { resolve(); } }); }); };