COMMAND: Improving error message for mv when a script is Running

* Adjusted error message to include information about making sure scripts are not running when trying to use mv on them.

* nom run format

* Added behaviour info to NetscriptDefinitions.d.ts

* `npm run doc`

* un-nested/inversed the check

* `npm run format`
This commit is contained in:
Chris Farfan de los Godos
2025-07-24 02:27:01 +03:00
committed by GitHub
parent ff106bb764
commit 8f69a6c0ee
4 changed files with 17 additions and 7 deletions
+10 -6
View File
@@ -1613,13 +1613,17 @@ export const ns: InternalAPI<NSFull> = {
throw helpers.errorMessage(ctx, `Source text file ${sourcePath} does not exist on ${host}`);
}
const success = sourceContentFile.deleteFromServer(server);
if (success) {
const { overwritten } = server.writeToContentFile(destinationPath, sourceContentFile.content);
if (overwritten) helpers.log(ctx, () => `WARNING: Overwriting file ${destinationPath} on ${host}`);
helpers.log(ctx, () => `Moved ${sourcePath} to ${destinationPath} on ${host}`);
return;
if (!success) {
helpers.log(
ctx,
() =>
`ERROR: Failed. Was unable to remove file ${sourcePath} from its original location. If ${sourcePath} is a script, make sure that it is NOT running before trying to use 'mv' on it.`,
);
}
helpers.log(ctx, () => `ERROR: Failed. Was unable to remove file ${sourcePath} from its original location.`);
const { overwritten } = server.writeToContentFile(destinationPath, sourceContentFile.content);
if (overwritten) helpers.log(ctx, () => `WARNING: Overwriting file ${destinationPath} on ${host}`);
helpers.log(ctx, () => `Moved ${sourcePath} to ${destinationPath} on ${host}`);
return;
},
getResetInfo: () => () => ({
lastAugReset: Player.lastAugReset,