summaryrefslogtreecommitdiff
path: root/server/frob/char.ts
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2019-10-01 17:15:09 -0400
committergumi <git@gumi.ca>2019-10-01 17:15:09 -0400
commitd34c1169ac71a0d3869b8fe9fb471ae2e135506b (patch)
treea0370dbebbbfec4517cfcc2a61ee96014a9b5007 /server/frob/char.ts
parentec8bf711a6970572afd52f85c62205e014f0babf (diff)
downloadtools-d34c1169ac71a0d3869b8fe9fb471ae2e135506b.tar.gz
tools-d34c1169ac71a0d3869b8fe9fb471ae2e135506b.tar.bz2
tools-d34c1169ac71a0d3869b8fe9fb471ae2e135506b.tar.xz
tools-d34c1169ac71a0d3869b8fe9fb471ae2e135506b.zip
[frob] allow to dry-run
Diffstat (limited to 'server/frob/char.ts')
-rw-r--r--server/frob/char.ts13
1 files changed, 9 insertions, 4 deletions
diff --git a/server/frob/char.ts b/server/frob/char.ts
index e5bb1e9..67751dc 100644
--- a/server/frob/char.ts
+++ b/server/frob/char.ts
@@ -136,13 +136,18 @@ class CharWriter {
}
}
- async finalize() {
+ async finalize(dry_run: boolean = false) {
console.info("appending %newid%...");
await Deno.write(this.file.rid, this.encoder.encode(`${this.highest + 1}\t%newid%\n`));
this.file.close();
- console.info("overwriting athena.txt...");
- await Deno.rename("world/save/athena.txt", "world/save/athena.txt_pre-frob");
- await Deno.rename("world/save/athena.txt.tmp", "world/save/athena.txt");
+
+ if (dry_run) {
+ Deno.removeSync("world/save/athena.txt.tmp");
+ } else {
+ console.info("overwriting athena.txt...");
+ await Deno.rename("world/save/athena.txt", "world/save/athena.txt_pre-frob");
+ await Deno.rename("world/save/athena.txt.tmp", "world/save/athena.txt");
+ }
}
}