Optional output capture in task runner

pull/99/head
Piero Toffanin 2020-01-21 17:07:13 -05:00
rodzic 315589c2de
commit 0d61a82129
2 zmienionych plików z 8 dodań i 6 usunięć

Wyświetl plik

@ -276,8 +276,6 @@ module.exports = class Task{
done(); done();
}else done(new Error(`Could not archive .zip file, 7z exited with code ${code}`)); }else done(new Error(`Could not archive .zip file, 7z exited with code ${code}`));
} }
}, output => {
this.output.push(output);
}); });
}; };
}; };

Wyświetl plik

@ -42,8 +42,10 @@ function makeRunner(command, args, requiredOptions = [], outputTestFile = null,
if (outputTestFile){ if (outputTestFile){
fs.readFile(path.resolve(__dirname, outputTestFile), 'utf8', (err, text) => { fs.readFile(path.resolve(__dirname, outputTestFile), 'utf8', (err, text) => {
if (!err){ if (!err){
if (outputReceived !== undefined){
let lines = text.split("\n"); let lines = text.split("\n");
lines.forEach(line => outputReceived(line)); lines.forEach(line => outputReceived(line));
}
done(null, 0, null); done(null, 0, null);
}else{ }else{
@ -71,8 +73,10 @@ function makeRunner(command, args, requiredOptions = [], outputTestFile = null,
.on('exit', (code, signal) => done(null, code, signal)) .on('exit', (code, signal) => done(null, code, signal))
.on('error', done); .on('error', done);
if (outputReceived !== undefined){
childProcess.stdout.on('data', chunk => outputReceived(chunk.toString())); childProcess.stdout.on('data', chunk => outputReceived(chunk.toString()));
childProcess.stderr.on('data', chunk => outputReceived(chunk.toString())); childProcess.stderr.on('data', chunk => outputReceived(chunk.toString()));
}
return childProcess; return childProcess;
}; };