You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
677 B
JavaScript

'use strict';
const childProcess = require("child_process");
const rfr = require("rfr");
const logStream = rfr("src/gulp/log-stream");
module.exports = function runProcess(path, args, options) {
if (options.logger != null) {
options.logger.info(`Starting ${path}...`);
}
let proc = childProcess.spawn(path, args, options);
if (options.logger != null) {
logStream(proc.stdout, options.logger.log);
logStream(proc.stderr, options.logger.error);
}
proc.on("error", (err) => {
if (options.logger != null) {
options.logger.error(err.stack);
}
});
proc.on("close", (code) => {
options.logger.info(`Exited with code ${code.toString()}: ${path}.`);
});
}