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'
* 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 === "") {
callingFnName = "getRunningScript";
}
@ -430,7 +435,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
let out = "";
for (let arg of args) {
arg = toNative(arg);
out += (typeof arg === "object") ? JSON.stringify(arg) : `${arg}`;
out += typeof arg === "object" ? JSON.stringify(arg) : `${arg}`;
}
return out;
@ -954,7 +959,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
if (killByPid) {
workerScript.log("kill", `No script with PID ${filename}`);
} 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;
}
@ -1020,7 +1028,6 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
}
destServer = safeGetServer(hostname2, "scp");
currServ = safeGetServer(hostname1, "scp");
} else if (hostname1 != null) {
// 2 Argument version: scriptname, destination
if (scriptname === undefined || hostname1 === undefined) {
@ -1029,7 +1036,10 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
destServer = safeGetServer(hostname1, "scp");
currServ = GetServer(workerScript.hostname);
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 {
throw makeRuntimeErrorMsg("scp", "Takes 2 or 3 arguments");
@ -1578,10 +1588,7 @@ function NetscriptFunctions(workerScript: WorkerScript): NS {
// Delete all scripts running on server
if (server.runningScripts.length > 0) {
workerScript.log(
"deleteServer",
`Cannot delete server '${hostname}' because it still has scripts running.`,
);
workerScript.log("deleteServer", `Cannot delete server '${hostname}' because it still has scripts running.`);
return false;
}