comparison env/lib/python3.7/site-packages/cwltool/cwlNodeEngineJSConsole.js @ 2:6af9afd405e9 draft

"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
author shellac
date Thu, 14 May 2020 14:56:58 -0400
parents 26e78fe6e8c4
children
comparison
equal deleted inserted replaced
1:75ca89e9b81c 2:6af9afd405e9
1 "use strict";
2 function js_console_log(){
3 console.error("[log] "+require("util").format.apply(this, arguments).split("\n").join("\n[log] "));
4 }
5 function js_console_err(){
6 console.error("[err] "+require("util").format.apply(this, arguments).split("\n").join("\n[err] "));
7 }
8 process.stdin.setEncoding("utf8");
9 var incoming = "";
10 process.stdin.on("data", function(chunk) {
11 incoming += chunk;
12 var i = incoming.indexOf("\n");
13 if (i > -1) {
14 try{
15 var fn = JSON.parse(incoming.substr(0, i));
16 incoming = incoming.substr(i+1);
17 process.stdout.write(JSON.stringify(require("vm").runInNewContext(fn, {
18 console: {
19 log: js_console_log,
20 error: js_console_err
21 }
22 })) + "\n");
23 }
24 catch(e){
25 console.error(e)
26 }
27 /*strings to indicate the process has finished*/
28 console.log("r1cepzbhUTxtykz5XTC4");
29 console.error("r1cepzbhUTxtykz5XTC4");
30 }
31 });
32 process.stdin.on("end", process.exit);