move object clearing logic to loadConfig function
All checks were successful
Build / build (18) (push) Successful in 42s
Build / build (20) (push) Successful in 1m16s
Build / build (22) (push) Successful in 40s
Build / build (20) (pull_request) Successful in 1m16s
Build / build (22) (pull_request) Successful in 40s
Build / build (18) (pull_request) Successful in 1m11s
All checks were successful
Build / build (18) (push) Successful in 42s
Build / build (20) (push) Successful in 1m16s
Build / build (22) (push) Successful in 40s
Build / build (20) (pull_request) Successful in 1m16s
Build / build (22) (pull_request) Successful in 40s
Build / build (18) (pull_request) Successful in 1m11s
This commit is contained in:
parent
27a10c972a
commit
19a5fb834f
@ -64,5 +64,11 @@ export const config: IConfig = {
|
||||
};
|
||||
|
||||
export const loadConfig = (): void => {
|
||||
// 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")));
|
||||
};
|
||||
|
@ -9,13 +9,6 @@ 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;
|
||||
}
|
||||
|
||||
try {
|
||||
loadConfig();
|
||||
} catch (e) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user