1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00
execjs/lib/execjs/support/node_runner.js
2012-05-20 12:26:27 -05:00

20 lines
532 B
JavaScript

(function(program, execJS) { execJS(program) })(function(module, exports, require, console) { #{source}
}, function(program) {
var output, print = function(string) {
process.stdout.write('' + string);
};
try {
result = program();
if (typeof result == 'undefined' && result !== null) {
print('["ok"]');
} else {
try {
print(JSON.stringify(['ok', result]));
} catch (err) {
print('["err"]');
}
}
} catch (err) {
print(JSON.stringify(['err', '' + err]));
}
});