now vm.Script options can accept context #54
Unanswered
ihorozheredov
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In scriptOptions of class MetaScript we can put context, but options of vm.Script don't accept it.
const scriptOptions = { filename: name, ...options, lineOffset };
this.script = new vm.Script(code, scriptOptions);
this.context = options.context || createContext();
https://github.com/metarhia/metavm/blob/85a4d2cae0e0f86c26323ab7e9cb6462252a3bbf/lib/vm.js#L40-L42
Maybe it would be better to do something like this:
const { context } = options;
this.context = context ? delete options.context && context : createContext();
const scriptOptions = { filename: name, ...options, lineOffset };
this.script = new vm.Script(code, scriptOptions);
Beta Was this translation helpful? Give feedback.
All reactions