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: use chokidar for configWatcherService (#2315)

It's just a lot snappier + works flawlessly under Bun. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2315 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

4f1f9592
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

3 个文件 +4 -11
Modified package-lock.json +1 -3
@@ -14,6 +14,7 @@
14 14 "@types/websocket": "^1.0.10",
15 15 "@types/ws": "^8.18.1",
16 16 "@typescript/native-preview": "^7.0.0-dev.20250625.1",
17 "chokidar": "^4.0.3",
17 18 "crc-32": "^1.2.2",
18 19 "express": "^5",
19 20 "json-with-bigint": "^3.4.4",
@@ -31,7 +32,6 @@
31 32 "devDependencies": {
32 33 "@typescript-eslint/eslint-plugin": "^8.28.0",
33 34 "@typescript-eslint/parser": "^8.28.0",
34 "chokidar": "^4.0.3",
35 35 "eslint": "^8",
36 36 "eslint-plugin-prettier": "^5.2.5",
37 37 "prettier": "^3.5.3",
@@ -997,7 +997,6 @@
997 997 "version": "4.0.3",
998 998 "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz",
999 999 "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==",
1000 "dev": true,
1001 1000 "license": "MIT",
1002 1001 "dependencies": {
1003 1002 "readdirp": "^4.0.1"
@@ -2803,7 +2802,6 @@
2803 2802 "version": "4.1.2",
2804 2803 "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz",
2805 2804 "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==",
2806 "dev": true,
2807 2805 "license": "MIT",
2808 2806 "engines": {
2809 2807 "node": ">= 14.18.0"
Modified package.json +1 -1
@@ -28,6 +28,7 @@
28 28 "@types/websocket": "^1.0.10",
29 29 "@types/ws": "^8.18.1",
30 30 "@typescript/native-preview": "^7.0.0-dev.20250625.1",
31 "chokidar": "^4.0.3",
31 32 "crc-32": "^1.2.2",
32 33 "express": "^5",
33 34 "json-with-bigint": "^3.4.4",
@@ -45,7 +46,6 @@
45 46 "devDependencies": {
46 47 "@typescript-eslint/eslint-plugin": "^8.28.0",
47 48 "@typescript-eslint/parser": "^8.28.0",
48 "chokidar": "^4.0.3",
49 49 "eslint": "^8",
50 50 "eslint-plugin-prettier": "^5.2.5",
51 51 "prettier": "^3.5.3",
Modified src/services/configWatcherService.ts +2 -7
@@ -1,4 +1,4 @@
1 import fs from "fs";
1 import chokidar from "chokidar";
2 2 import fsPromises from "fs/promises";
3 3 import { logger } from "../utils/logger";
4 4 import { config, configPath, loadConfig } from "./configService";
@@ -6,12 +6,7 @@ import { getWebPorts, sendWsBroadcast, startWebServer, stopWebServer } from "./w
6 6 import { Inbox } from "../models/inboxModel";
7 7
8 8 let amnesia = false;
9 fs.watchFile(configPath, (now, then) => {
10 // https://github.com/oven-sh/bun/issues/20542
11 if (process.versions.bun && now.mtimeMs == then.mtimeMs) {
12 return;
13 }
14
9 chokidar.watch(configPath).on("change", () => {
15 10 if (amnesia) {
16 11 amnesia = false;
17 12 } else {