Skip to content

Commit 04ff6dc

Browse files
committed
Added support for command stdout redirection to a file
1 parent dab94e3 commit 04ff6dc

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

converters/pegasus_dax.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ function createWorkflow(dax, functionName, cb) {
111111
"outs": []
112112
});
113113

114+
if (job.stdout) { // stdout should be redirected to a file
115+
console.log(job.stdout);
116+
wfOut.tasks[nextTaskId].config.executor.stdout = job.stdout[0]['$'].name;
117+
}
118+
114119
if (job['$'].runtime) { // synthetic workflow dax
115120
wfOut.tasks[nextTaskId].runtime = job['$'].runtime;
116121
}

functions/command.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
1-
var spawn = require('cross-spawn');
1+
var spawn = require('cross-spawn'),
2+
fs = require('fs');
23

34
function command(ins, outs, config, cb) {
45
var exec = config.executor.executable,
56
args = config.executor.args;
67

8+
var stdoutStream;
9+
710
console.log("Executing:", exec, args);
811

912
// var proc = spawn(exec, [ args ]);
1013
var proc = spawn(exec, args );
1114

15+
if (config.executor.stdout) {
16+
stdoutStream = fs.createWriteStream(config.executor.stdout, {flags: 'w'});
17+
proc.stdout.pipe(stdoutStream);
18+
}
19+
1220
proc.stdout.on('data', function(data) {
1321
console.log(exec, 'stdout:' + data);
1422
});

0 commit comments

Comments
 (0)