aboutsummaryrefslogtreecommitdiffstats
path: root/tools/execute_js_code.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/execute_js_code.js')
-rw-r--r--tools/execute_js_code.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/execute_js_code.js b/tools/execute_js_code.js
index 853ccab..6bad67a 100644
--- a/tools/execute_js_code.js
+++ b/tools/execute_js_code.js
@@ -1,3 +1,5 @@
+const vm = require('vm');
+
/**
* Execute the javascript code in node.js.
* @typedef {Object} Args
@@ -5,5 +7,7 @@
* @param {Args} args
*/
exports.run = function run({ code }) {
- return eval(code);
+ const context = vm.createContext({});
+ const script = new vm.Script(code);
+ return script.runInContext(context);
}