From fa8d630283145759e7d62ee51e4c1eacc088e417 Mon Sep 17 00:00:00 2001 From: Ruakij Date: Wed, 24 Nov 2021 15:35:05 +0100 Subject: [PATCH] Change exec to just return process and streams --- src/helper/exec.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/helper/exec.js b/src/helper/exec.js index b618e3e..63f6c69 100644 --- a/src/helper/exec.js +++ b/src/helper/exec.js @@ -3,17 +3,18 @@ const logger = require("./logger.js")("exec"); 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(' ') logger.addContext("binary", "bin"); logger.debug(`Spawn process '${cmd}'`); let proc = spawn(bin, args); - logger.debug(`Attach stdout, stderr and exit-handler if set`); - stdout_handler && proc.stdout.on('data', stdout_handler); - stderr_handler && proc.stderr.on('data', stderr_handler); - exit_handler && proc.on('exit', exit_handler); + return { + "process": proc, + "stdout": proc.stdout, + "stderr": proc.stderr + } } // Specify exports