1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00
execjs/lib/execjs/support/jscript_runner.js
2015-02-25 14:13:34 -06:00

22 lines
623 B
JavaScript

(function(program, execJS) { execJS(program) })(function() {
return eval(#{encode_source(source)});
}, function(program) {
#{json2_source}
var output, print = function(string) {
WScript.Echo(string);
};
try {
result = program();
if (typeof result == 'undefined' && result !== null) {
print('["ok"]');
} else {
try {
print(JSON.stringify(['ok', result]));
} catch (err) {
print(JSON.stringify(['err', err.name + ': ' + err.message, err.stack]));
}
}
} catch (err) {
print(JSON.stringify(['err', err.name + ': ' + err.message, err.stack]));
}
});