diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2023-04-19 23:26:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-19 23:26:16 +0900 |
commit | 53c9f5918cd07237c20b086945d4604baf1900fb (patch) | |
tree | 5453468f15e25fe30a0c1d38bf710f8194516823 /ext | |
parent | fdebb7e7930b175b5dd80f891253000a29c82a4a (diff) |
fix(ext/node): improve vm.runInThisContext (#18767)
Diffstat (limited to 'ext')
-rw-r--r-- | ext/node/polyfills/vm.ts | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/node/polyfills/vm.ts b/ext/node/polyfills/vm.ts index cb12f88e7..4ca375e88 100644 --- a/ext/node/polyfills/vm.ts +++ b/ext/node/polyfills/vm.ts @@ -4,6 +4,8 @@ import { notImplemented } from "ext:deno_node/_utils.ts"; +const { core } = globalThis.__bootstrap; + export class Script { code: string; constructor(code: string, _options = {}) { @@ -11,7 +13,11 @@ export class Script { } runInThisContext(_options: any) { - return eval.call(globalThis, this.code); + const [result, error] = core.evalContext(this.code, "data:"); + if (error) { + throw error.thrown; + } + return result; } runInContext(_contextifiedObject: any, _options: any) { |