diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 457173d9..703b7eaf 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -5,4 +5,4 @@ if [ ! -f conf/config.json ]; then jq --arg value "mongodb://openwfagent:spaceninjaserver@mongodb:27017/" '.mongodbUrl = $value' /app/config.json.example > /app/conf/config.json fi -exec npm run start conf/config.json +exec npm run start -- --configPath conf/config.json diff --git a/scripts/dev.js b/scripts/dev.js index 55b77998..da3a0477 100644 --- a/scripts/dev.js +++ b/scripts/dev.js @@ -20,11 +20,11 @@ function run(changedFile) { runproc = undefined; } - buildproc = spawn("npm", ["run", "build", ...args], { stdio: "inherit", shell: true }); + buildproc = spawn("npm", ["run", "build"], { stdio: "inherit", shell: true }); buildproc.on("exit", code => { buildproc = undefined; if (code === 0) { - runproc = spawn("npm", ["run", "start", ...args], { stdio: "inherit", shell: true }); + runproc = spawn("npm", ["run", "start", "--", "--dev", ...args], { stdio: "inherit", shell: true }); runproc.on("exit", () => { runproc = undefined; }); diff --git a/src/helpers/commandLineArguments.ts b/src/helpers/commandLineArguments.ts new file mode 100644 index 00000000..30938abf --- /dev/null +++ b/src/helpers/commandLineArguments.ts @@ -0,0 +1,18 @@ +interface IArguments { + configPath?: string; + dev?: boolean; +} + +export const args: IArguments = {}; + +for (let i = 2; i < process.argv.length; ) { + switch (process.argv[i++]) { + case "--configPath": + args.configPath = process.argv[i++]; + break; + + case "--dev": + args.dev = true; + break; + } +} diff --git a/src/helpers/pathHelper.ts b/src/helpers/pathHelper.ts index 94a0f242..37e87dff 100644 --- a/src/helpers/pathHelper.ts +++ b/src/helpers/pathHelper.ts @@ -1,5 +1,4 @@ import path from "path"; export const rootDir = path.join(__dirname, "../.."); -export const isDev = path.basename(rootDir) != "build"; -export const repoDir = isDev ? rootDir : path.join(rootDir, ".."); +export const repoDir = path.basename(rootDir) != "build" ? rootDir : path.join(rootDir, ".."); diff --git a/src/services/configService.ts b/src/services/configService.ts index b4566096..6ef2e96f 100644 --- a/src/services/configService.ts +++ b/src/services/configService.ts @@ -1,6 +1,7 @@ import fs from "fs"; import path from "path"; import { repoDir } from "@/src/helpers/pathHelper"; +import { args } from "@/src/helpers/commandLineArguments"; export interface IConfig { mongodbUrl: string; @@ -79,7 +80,7 @@ export interface IConfig { }; } -export const configPath = path.join(repoDir, process.argv[2] ?? "config.json"); +export const configPath = path.join(repoDir, args.configPath ?? "config.json"); export const config: IConfig = { mongodbUrl: "mongodb://127.0.0.1:27017/openWF", diff --git a/src/services/serversideVendorsService.ts b/src/services/serversideVendorsService.ts index 774180d6..0e4b3856 100644 --- a/src/services/serversideVendorsService.ts +++ b/src/services/serversideVendorsService.ts @@ -1,5 +1,5 @@ import { unixTimesInMs } from "@/src/constants/timeConstants"; -import { isDev } from "@/src/helpers/pathHelper"; +import { args } from "@/src/helpers/commandLineArguments"; import { catBreadHash } from "@/src/helpers/stringHelpers"; import { TInventoryDatabaseDocument } from "@/src/models/inventoryModels/inventoryModel"; import { mixSeeds, SRng } from "@/src/services/rngService"; @@ -421,7 +421,7 @@ const generateVendorManifest = (vendorInfo: IGeneratableVendorInfo): IVendorMani return cacheEntry; }; -if (isDev) { +if (args.dev) { if ( getCycleDuration(ExportVendors["/Lotus/Types/Game/VendorManifests/Hubs/TeshinHardModeVendorManifest"]) != unixTimesInMs.week