XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 0 Star 0
返回提交历史

XFEstudio/XFESpaceNinjaServer

chore: support config path being specified via command line argument (#2201)

Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2201 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

0c406561
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +6 -6
Modified src/index.ts +3 -3
@@ -1,13 +1,13 @@
1 1 // First, init config.
2 import { config, loadConfig } from "@/src/services/configService";
2 import { config, configPath, loadConfig } from "@/src/services/configService";
3 3 import fs from "fs";
4 4 try {
5 5 loadConfig();
6 6 } catch (e) {
7 7 if (fs.existsSync("config.json")) {
8 console.log("Failed to load config.json: " + (e as Error).message);
8 console.log("Failed to load " + configPath + ": " + (e as Error).message);
9 9 } else {
10 console.log("Failed to load config.json. You can copy config.json.example to create your config.json.");
10 console.log("Failed to load " + configPath + ". You can copy config.json.example to create your config file.");
11 11 }
12 12 process.exit(1);
13 13 }
Modified src/services/configService.ts +1 -1
@@ -72,7 +72,7 @@ export interface IConfig {
72 72 };
73 73 }
74 74
75 export const configPath = path.join(repoDir, "config.json");
75 export const configPath = path.join(repoDir, process.argv[2] ?? "config.json");
76 76
77 77 export const config: IConfig = {
78 78 mongodbUrl: "mongodb://127.0.0.1:27017/openWF",
Modified src/services/configWatcherService.ts +2 -2
@@ -9,7 +9,7 @@ fs.watchFile(configPath, () => {
9 9 if (amnesia) {
10 10 amnesia = false;
11 11 } else {
12 logger.info("Detected a change to config.json, reloading its contents.");
12 logger.info("Detected a change to config file, reloading its contents.");
13 13 try {
14 14 loadConfig();
15 15 } catch (e) {
@@ -41,7 +41,7 @@ export const validateConfig = (): void => {
41 41 }
42 42 }
43 43 if (modified) {
44 logger.info(`Updating config.json to fix some issues with it.`);
44 logger.info(`Updating config file to fix some issues with it.`);
45 45 void saveConfig();
46 46 }
47 47 };