(cmd, argv, options)
| 6 | // Expose utility |
| 7 | |
| 8 | function run(cmd, argv, options) { |
| 9 | if (!argv) |
| 10 | argv = []; |
| 11 | var index = 0; |
| 12 | while (index < argv.length) { |
| 13 | if (argv[index] == null) |
| 14 | argv.splice(index, 1); |
| 15 | else if (Array.isArray(argv[index])) { |
| 16 | if (argv[index].some(item => item == null)) |
| 17 | argv.splice(index, 1); |
| 18 | else |
| 19 | Array.prototype.splice.apply(argv, [ index, 1 ].concat(argv[index])); |
| 20 | } else |
| 21 | ++index; |
| 22 | } |
| 23 | if (!(options && options.quiet)) |
| 24 | process.stderr.write(chalk.white.bold(path.basename(cmd)) + " " + argv.map((arg, i) => i === argv.length - 1 || arg.charAt(0) === "-" ? "\n " + arg : arg).join(" ") + "\n\n"); |
| 25 | return new Promise(function(resolve, reject) { |
| 26 | var proc = child_process.spawn(cmd, argv, { stdio: "inherit" }); |
| 27 | proc.on("close", function(code) { |
| 28 | if (code === 0) |
| 29 | resolve(); |
| 30 | else |
| 31 | reject(new Error("code " + code)); |
| 32 | }); |
| 33 | proc.on("error", function(err) { |
| 34 | reject(err); |
| 35 | }); |
| 36 | }); |
| 37 | } |
| 38 | |
| 39 | exports.run = run; |
| 40 |
no outgoing calls
no test coverage detected