mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-08 08:43:53 +01:00
properly fix leading '/' script bug (#296)
This commit is contained in:
parent
aa32e235fa
commit
3281b785ce
@ -421,9 +421,6 @@ export function runScriptFromScript(
|
||||
return 0;
|
||||
}
|
||||
|
||||
//prevent leading / from causing a bug
|
||||
if (scriptname.startsWith("/")) scriptname = scriptname.slice(1);
|
||||
|
||||
if (typeof scriptname !== "string" || !Array.isArray(args)) {
|
||||
workerScript.log(caller, () => `Invalid arguments: scriptname='${scriptname} args='${args}'`);
|
||||
console.error(`runScriptFromScript() failed due to invalid arguments`);
|
||||
|
@ -129,7 +129,12 @@ export abstract class BaseServer {
|
||||
*/
|
||||
getRunningScript(scriptName: string, scriptArgs: ScriptArg[]): RunningScript | null {
|
||||
for (const rs of this.runningScripts) {
|
||||
if (rs.filename === scriptName && compareArrays(rs.args, scriptArgs)) {
|
||||
//compare file names without leading '/' to prevent running multiple script with the same name
|
||||
if (
|
||||
(rs.filename.charAt(0) == "/" ? rs.filename.slice(1) : rs.filename) ===
|
||||
(scriptName.charAt(0) == "/" ? scriptName.slice(1) : scriptName) &&
|
||||
compareArrays(rs.args, scriptArgs)
|
||||
) {
|
||||
return rs;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user