'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}.`); }); }