Skip to content

Commit b49cd22

Browse files
committed
another attempt to fix js-console logging within eval
1 parent 1e3a5a2 commit b49cd22

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

cwltool/cwlNodeEngineJSConsole.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
"use strict";
2+
function js_console_log(){
3+
console.error("[log] "+util.format.apply(this, arguments).split("\n").join("\n[log] "));
4+
}
5+
function js_console_err(){
6+
console.error("[err] "+util.format.apply(this, arguments).split("\n").join("\n[err] "));
7+
}
28
process.stdin.setEncoding("utf8");
39
var incoming = "";
410
process.stdin.on("data", function(chunk) {
@@ -8,14 +14,9 @@ process.stdin.on("data", function(chunk) {
814
var fn = JSON.parse(incoming.substr(0, i));
915
incoming = incoming.substr(i+1);
1016
process.stdout.write(JSON.stringify(require("vm").runInNewContext(fn, {
11-
util: {format: util.format},
1217
console: {
13-
log: function(){
14-
console.error("[log] "+util.format.apply(this, arguments).split("\n").join("\n[log] "));
15-
},
16-
error: function(){
17-
console.error("[err] "+util.format.apply(this, arguments).split("\n").join("\n[err] "));
18-
}
18+
log: js_console_log,
19+
error: js_console_err
1920
}
2021
})) + "\n");
2122
}

0 commit comments

Comments
 (0)