From 31e301866595407db199899968d9c2cf68b89342 Mon Sep 17 00:00:00 2001 From: aquacluck Date: Sun, 9 Jul 2023 12:45:51 -0700 Subject: [PATCH] Fix arg handling compatibility --- README.md | 4 ++++ build.ts | 15 ++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a47c43..1848d43 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ A server for querying placement objects in *The Legend of Zelda: Tears of the Ki Run build.ts to generate a map database before starting the server for the first time. + ts-node build.ts -d ../totk/Banc + +This assumes the `totk/Banc` directory contains the YAML data object map files + ts-node build.ts -r ../totk -e tools This assumes the `totk` directory contains the unaltered romfs contents. diff --git a/build.ts b/build.ts index 8c182c7..5765370 100644 --- a/build.ts +++ b/build.ts @@ -7,17 +7,22 @@ import { Beco } from './beco'; let parseArgs = require('minimist'); let argv = parseArgs(process.argv); -if (!argv.e || !argv.r) { - console.log("Error: Must specify paths to directories with "); +const validRomfsArgs = (argv.e && argv.r); +const validFolderArgs = (argv.e && argv.b && argv.d); +if (!validRomfsArgs && !validFolderArgs) { + console.log("Error: Must specify paths to directories with -e and either -r or (-b and -d)"); + console.log(" -d Banc extracted YAML files"); + console.log(" -b field map area beco files"); console.log(" -e Ecosystem json files"); console.log(" -r Bare game romfs"); - console.log(" e.g. % ts-node build.ts -r path/to/romfs -e tools") + console.log(" e.g. % ts-node build.ts -d path/to/Banc -b path/to/beco -e path/to/Ecosystem") + console.log(" or: % ts-node build.ts -r path/to/romfs -e path/to/Ecosystem") process.exit(1); } const ecoPath = argv.e; const romfsPath = argv.r; -const totkData = path.join(romfsPath, 'Banc'); -const becoPath = path.join(romfsPath, 'Ecosystem', 'FieldMapArea'); +const totkData = argv.d || path.join(romfsPath, 'Banc'); +const becoPath = argv.b || path.join(romfsPath, 'Ecosystem', 'FieldMapArea'); fs.rmSync('map.db.tmp', { force: true }); const db = sqlite3('map.db.tmp');