Threads are a positive integer (#366)

* Added new positive integer ns validation helper
* `run`, `exec`, and `spawn` verify threads as a positive integer.
* `run` terminal command also fails if the provided threadcount is not a positive integer.
* Removed some references to .script files in various documentation, and removed some of the NS1 example blocks
This commit is contained in:
Snarling
2023-02-14 01:32:01 -05:00
committed by GitHub
parent b0bdf0c7ad
commit 08e71c732b
20 changed files with 165 additions and 474 deletions
+3 -4
View File
@@ -22,13 +22,12 @@ export function runScript(commandArgs: (string | number | boolean)[], server: Ba
permissive: true,
argv: commandArgs.slice(1),
});
const threadFlag = Math.round(parseFloat(flags["-t"]));
const tailFlag = flags["--tail"] === true;
if (flags["-t"] !== undefined && (threadFlag < 0 || isNaN(threadFlag))) {
Terminal.error("Invalid number of threads specified. Number of threads must be greater than 0");
const numThreads = parseFloat(flags["-t"] ?? 1);
if (numThreads < 1 || !Number.isInteger(numThreads)) {
Terminal.error("Invalid number of threads specified. Number of threads must be an integer greater than 0");
return;
}
const numThreads = !isNaN(threadFlag) && threadFlag > 0 ? threadFlag : 1;
const args = flags["_"];
// Check if this script is already running