fix: configService not handling a field being removed from config.json

This commit is contained in:
Sainan 2024-12-23 19:34:07 +01:00
parent 6b9fd766e0
commit 6e27eea7bb

View File

@ -14,6 +14,13 @@ fs.watchFile(configPath, () => {
amnesia = false;
} else {
logger.info("Detected a change to config.json, reloading its contents.");
// Set all values to undefined now so if the new config.json omits some fields that were previously present, it's correct in-memory.
for (const key of Object.keys(config)) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access
(config as any)[key] = undefined;
}
Object.assign(config, JSON.parse(fs.readFileSync(configPath, "utf-8")));
}
});