From 0d61a82129acb1479b18820295a2e2d07348c3b8 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Tue, 21 Jan 2020 17:07:13 -0500 Subject: [PATCH] Optional output capture in task runner --- libs/Task.js | 2 -- libs/processRunner.js | 12 ++++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/libs/Task.js b/libs/Task.js index f595ac1..1fb07d7 100644 --- a/libs/Task.js +++ b/libs/Task.js @@ -276,8 +276,6 @@ module.exports = class Task{ done(); }else done(new Error(`Could not archive .zip file, 7z exited with code ${code}`)); } - }, output => { - this.output.push(output); }); }; }; diff --git a/libs/processRunner.js b/libs/processRunner.js index 5739722..f6b0ab0 100644 --- a/libs/processRunner.js +++ b/libs/processRunner.js @@ -42,8 +42,10 @@ function makeRunner(command, args, requiredOptions = [], outputTestFile = null, if (outputTestFile){ fs.readFile(path.resolve(__dirname, outputTestFile), 'utf8', (err, text) => { if (!err){ - let lines = text.split("\n"); - lines.forEach(line => outputReceived(line)); + if (outputReceived !== undefined){ + let lines = text.split("\n"); + lines.forEach(line => outputReceived(line)); + } done(null, 0, null); }else{ @@ -71,8 +73,10 @@ function makeRunner(command, args, requiredOptions = [], outputTestFile = null, .on('exit', (code, signal) => done(null, code, signal)) .on('error', done); - childProcess.stdout.on('data', chunk => outputReceived(chunk.toString())); - childProcess.stderr.on('data', chunk => outputReceived(chunk.toString())); + if (outputReceived !== undefined){ + childProcess.stdout.on('data', chunk => outputReceived(chunk.toString())); + childProcess.stderr.on('data', chunk => outputReceived(chunk.toString())); + } return childProcess; };