mirror of
https://github.com/denoland/deno.git
synced 2025-10-02 15:14:33 +00:00
fix(ext/node): improve vm.runInThisContext (#18767)
This commit is contained in:
parent
fdebb7e793
commit
53c9f5918c
4 changed files with 87 additions and 4 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue