File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed
Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22
3- const fs = require ( 'node:fs' ) . promises ;
4- const vm = require ( 'node:vm' ) ;
53const http = require ( 'node:http' ) ;
4+ const metavm = require ( 'metavm' ) ;
65
7- const RUN_OPTIONS = { timeout : 5000 , displayErrors : false } ;
86const INTERVAL = 500 ;
97
10- const load = async ( filePath , sandbox ) => {
11- // TODO Use metavm
12- const src = await fs . readFile ( filePath , 'utf8' ) ;
13- const code = `'use strict';\n${ src } ` ;
14- const script = new vm . Script ( code ) ;
15- const context = vm . createContext ( Object . freeze ( { ...sandbox } ) ) ;
16- const exports = script . runInContext ( context , RUN_OPTIONS ) ;
8+ const load = async ( filePath ) => {
9+ const { exports } = await metavm . readScript ( filePath ) ;
1710 return exports ;
1811} ;
1912
@@ -79,8 +72,7 @@ const apiReady = async ({ url, timeout }) => {
7972} ;
8073
8174const loadConfig = async ( configName ) => {
82- const sandbox = { Map : class PseudoMap { } } ;
83- return load ( `./application/config/${ configName } .js` , sandbox ) ;
75+ return load ( `./application/config/${ configName } .js` ) ;
8476} ;
8577
8678const getUrl = async ( ) => {
You can’t perform that action at this time.
0 commit comments