This commit is contained in:
Olivier Gagnon 2021-10-23 10:09:43 -04:00
parent eec75b0840
commit 9493768c0b

@ -166,7 +166,12 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
* exists, or the current running script if the first argument 'fn' * exists, or the current running script if the first argument 'fn'
* is not specified. * is not specified.
*/ */
const getRunningScript = function (fn: any, hostname: any, callingFnName: any, scriptArgs: any): RunningScript | null { const getRunningScript = function (
fn: any,
hostname: any,
callingFnName: any,
scriptArgs: any,
): RunningScript | null {
if (typeof callingFnName !== "string" || callingFnName === "") { if (typeof callingFnName !== "string" || callingFnName === "") {
callingFnName = "getRunningScript"; callingFnName = "getRunningScript";
} }
@ -430,7 +435,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
let out = ""; let out = "";
for (let arg of args) { for (let arg of args) {
arg = toNative(arg); arg = toNative(arg);
out += (typeof arg === "object") ? JSON.stringify(arg) : `${arg}`; out += typeof arg === "object" ? JSON.stringify(arg) : `${arg}`;
} }
return out; return out;
@ -954,7 +959,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (killByPid) { if (killByPid) {
workerScript.log("kill", `No script with PID ${filename}`); workerScript.log("kill", `No script with PID ${filename}`);
} else { } else {
workerScript.log("kill", `No such script '${filename}' on '${hostname}' with args: ${arrayToString(scriptArgs)}`); workerScript.log(
"kill",
`No such script '${filename}' on '${hostname}' with args: ${arrayToString(scriptArgs)}`,
);
} }
return false; return false;
} }
@ -1020,7 +1028,6 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
} }
destServer = safeGetServer(hostname2, "scp"); destServer = safeGetServer(hostname2, "scp");
currServ = safeGetServer(hostname1, "scp"); currServ = safeGetServer(hostname1, "scp");
} else if (hostname1 != null) { } else if (hostname1 != null) {
// 2 Argument version: scriptname, destination // 2 Argument version: scriptname, destination
if (scriptname === undefined || hostname1 === undefined) { if (scriptname === undefined || hostname1 === undefined) {
@ -1029,7 +1036,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
destServer = safeGetServer(hostname1, "scp"); destServer = safeGetServer(hostname1, "scp");
currServ = GetServer(workerScript.hostname); currServ = GetServer(workerScript.hostname);
if (currServ == null) { if (currServ == null) {
throw makeRuntimeErrorMsg("scp", "Could not find server hostname for this script. This is a bug. Report to dev."); throw makeRuntimeErrorMsg(
"scp",
"Could not find server hostname for this script. This is a bug. Report to dev.",
);
} }
} else { } else {
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments"); throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
@ -1578,10 +1588,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
// Delete all scripts running on server // Delete all scripts running on server
if (server.runningScripts.length > 0) { if (server.runningScripts.length > 0) {
workerScript.log( workerScript.log("deleteServer", `Cannot delete server '${hostname}' because it still has scripts running.`);
"deleteServer",
`Cannot delete server '${hostname}' because it still has scripts running.`,
);
return false; return false;
} }