diff --git a/lib/execjs/support/bun_runner.js b/lib/execjs/support/bun_runner.js index ddbdedf..f5bd11a 100644 --- a/lib/execjs/support/bun_runner.js +++ b/lib/execjs/support/bun_runner.js @@ -1,4 +1,4 @@ -(function(program, execJS) { (function() {execJS(program) }).call({}); })(function(self, global, process, module, exports, require, console, setTimeout, setInterval, clearTimeout, clearInterval, setImmediate, clearImmediate) { #{source} +(function(program, execJS) { (function() {execJS(program) }).call({}); })(async function(self, global, process, module, exports, require, console, setTimeout, setInterval, clearTimeout, clearInterval, setImmediate, clearImmediate) { #{source} }, function(program) { // Force BunJS to use sloppy mode see https://github.com/oven-sh/bun/issues/4527#issuecomment-1709520894 exports.abc = function(){} @@ -11,17 +11,21 @@ try { delete this.process; delete this.console; - result = program(); - process = __process__; - if (typeof result == 'undefined' && result !== null) { - printFinal('["ok"]'); - } else { - try { - printFinal(JSON.stringify(['ok', result])); - } catch (err) { - printFinal(JSON.stringify(['err', '' + err, err.stack])); + (program()).then((result) => { + process = __process__; + if (typeof result == 'undefined' && result !== null) { + printFinal('["ok"]'); + } else { + try { + printFinal(JSON.stringify(['ok', result])); + } catch (err) { + printFinal(JSON.stringify(['err', '' + err, err.stack])); + } } - } + }).catch((err) => { + process = __process__; + printFinal(JSON.stringify(['err', '' + err, err.stack])); + }) } catch (err) { process = __process__; printFinal(JSON.stringify(['err', '' + err, err.stack]));