001-drive-proxy-adapter #1
@@ -89,12 +89,13 @@ function loadGlobalVariableFunctions() {
|
||||
const code = readFileSync(filePath, "utf-8");
|
||||
const script = new vm.Script(code, { filename: file });
|
||||
|
||||
// Execute in context with crypto and console
|
||||
// Expects file to return an object via IIFE
|
||||
// Execute in context with all VM globals and previously loaded variables
|
||||
// Allows function modules to access same dependencies as proxy.js
|
||||
const tempContext = vm.createContext({
|
||||
crypto,
|
||||
console: logger,
|
||||
...globalVMContext,
|
||||
...globalVariableContext,
|
||||
});
|
||||
|
||||
const exportedObject = script.runInContext(tempContext);
|
||||
|
||||
globalVariableContext[functionName] = exportedObject;
|
||||
|
||||
Reference in New Issue
Block a user