fix undying script bug

This commit is contained in:
Olivier Gagnon
2021-12-14 19:39:55 -05:00
parent 4d80813707
commit 5b38ee3cfb
6 changed files with 17 additions and 10 deletions
+8 -5
View File
@@ -941,6 +941,7 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
return runScriptFromScript("run", scriptServer, scriptname, args, workerScript, threads);
},
exec: function (scriptname: any, hostname: any, threads: any = 1, ...args: any[]): any {
console.log(`${scriptname} ${hostname} ${threads} ${JSON.stringify(args)}`);
updateDynamicRam("exec", getRamCost("exec"));
if (scriptname === undefined || hostname === undefined) {
throw makeRuntimeErrorMsg("exec", "Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
@@ -1061,11 +1062,13 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
throw makeRuntimeErrorMsg("scp", "No scripts to copy");
}
let res = true;
await Promise.all(scripts.map(async function(script) {
if (!await NetscriptFunctions(workerScript).scp(script, hostname1, hostname2)) {
res = false;
}
}));
await Promise.all(
scripts.map(async function (script) {
if (!(await NetscriptFunctions(workerScript).scp(script, hostname1, hostname2))) {
res = false;
}
}),
);
return Promise.resolve(res);
}