mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 01:03:01 +02:00
Changed NSJS to take in nsEnv as an argument to main
This commit is contained in:
@@ -41,13 +41,7 @@ export async function executeJSScript(script, scripts = [], workerScript) {
|
||||
throw makeRuntimeRejectMsg(script.filename +
|
||||
" did not have a main function, cannot run it.");
|
||||
}
|
||||
console.log("loadedModule:");
|
||||
console.log(loadedModule);
|
||||
let constructedModule = await ConstructModule(loadedModule, ns);
|
||||
constructedModule = await constructedModule();
|
||||
console.log("constructedModule: ");
|
||||
console.log(constructedModule);
|
||||
return constructedModule.main();
|
||||
return loadedModule.main(ns);
|
||||
} finally {
|
||||
// Revoke the generated URLs
|
||||
if (urlStack != null) {
|
||||
@@ -56,26 +50,6 @@ export async function executeJSScript(script, scripts = [], workerScript) {
|
||||
};
|
||||
}
|
||||
|
||||
export function ConstructModule(module, ns) {
|
||||
function mod() {
|
||||
/*
|
||||
for (var fn in ns) {
|
||||
let fooName = fn.toString();
|
||||
var evalStatement = "var " + fooName + " = ns[\"" + fooName + "\"];"
|
||||
console.log(evalStatement);
|
||||
eval(evalStatement);
|
||||
console.log(ns[fooName]);
|
||||
console.log("Setting " + fooName + " in ConstructModule()");
|
||||
console.log(fooName);
|
||||
console.log(" ");
|
||||
}*/
|
||||
var newModule = Object.create(module);
|
||||
newModule.tprint = ns.tprint;
|
||||
return newModule;
|
||||
}
|
||||
return mod;
|
||||
}
|
||||
|
||||
// Gets a stack of blob urls, the top/right-most element being
|
||||
// the blob url for the named script on the named server.
|
||||
//
|
||||
@@ -119,6 +93,7 @@ function _getScriptUrls(script, scripts, seen) {
|
||||
return [prefix, urls[urls.length - 1], suffix].join('');
|
||||
});
|
||||
|
||||
|
||||
// If we successfully transformed the code, create a blob url for it and
|
||||
// push that URL onto the top of the stack.
|
||||
urlStack.push(URL.createObjectURL(makeScriptBlob(transformedCode)));
|
||||
|
||||
Reference in New Issue
Block a user