mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-19 15:54:09 +02:00
Ignore trailing whitespace for dirty file asterisk
Saved scripts is stored on servers with its starting & trailing whitespace removed, so comparison would fail and show the file as dirty when there was a trailing newline in the script.
This commit is contained in:
+10
-1
@@ -118,7 +118,7 @@ export class Script {
|
||||
*/
|
||||
saveScript(player: IPlayer, filename: string, code: string, hostname: string, otherScripts: Script[]): void {
|
||||
// Update code and filename
|
||||
this.code = code.replace(/^\s+|\s+$/g, "");
|
||||
this.code = Script.formatCode(this.code);
|
||||
|
||||
this.filename = filename;
|
||||
this.server = hostname;
|
||||
@@ -158,6 +158,15 @@ export class Script {
|
||||
s.rehash();
|
||||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats code: Removes the starting & trailing whitespace
|
||||
* @param {string} code - The code to format
|
||||
* @returns The formatted code
|
||||
*/
|
||||
static formatCode(code: string): string {
|
||||
return code.replace(/^\s+|\s+$/g, "");
|
||||
}
|
||||
}
|
||||
|
||||
Reviver.constructors.Script = Script;
|
||||
|
||||
Reference in New Issue
Block a user