mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-28 20:07:04 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user