fix(ext/node): improve vm.runInThisContext (#18767)

This commit is contained in:
Yoshiya Hinosawa 2023-04-19 23:26:16 +09:00 committed by GitHub
parent fdebb7e793
commit 53c9f5918c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 87 additions and 4 deletions

View file

@ -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) {