Change exec to just return process and streams
This commit is contained in:
parent
9c28ed53e3
commit
fa8d630283
@ -3,17 +3,18 @@ const logger = require("./logger.js")("exec");
|
|||||||
const { spawn } = require("child_process");
|
const { spawn } = require("child_process");
|
||||||
|
|
||||||
|
|
||||||
function exec(cmd, stdout_handler, stderr_handler, exit_handler){
|
function exec(cmd, stdout, stderr, exit_handler){
|
||||||
const [bin, ...args] = cmd.split(' ')
|
const [bin, ...args] = cmd.split(' ')
|
||||||
|
|
||||||
logger.addContext("binary", "bin");
|
logger.addContext("binary", "bin");
|
||||||
logger.debug(`Spawn process '${cmd}'`);
|
logger.debug(`Spawn process '${cmd}'`);
|
||||||
let proc = spawn(bin, args);
|
let proc = spawn(bin, args);
|
||||||
|
|
||||||
logger.debug(`Attach stdout, stderr and exit-handler if set`);
|
return {
|
||||||
stdout_handler && proc.stdout.on('data', stdout_handler);
|
"process": proc,
|
||||||
stderr_handler && proc.stderr.on('data', stderr_handler);
|
"stdout": proc.stdout,
|
||||||
exit_handler && proc.on('exit', exit_handler);
|
"stderr": proc.stderr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specify exports
|
// Specify exports
|
||||||
|
Loading…
x
Reference in New Issue
Block a user