we should get a type error when attempting to access a removed option on config
This commit is contained in:
parent
b5c6c3e485
commit
8d527af2e9
@ -4,7 +4,7 @@ import { repoDir } from "../helpers/pathHelper.ts";
|
|||||||
import { args } from "../helpers/commandLineArguments.ts";
|
import { args } from "../helpers/commandLineArguments.ts";
|
||||||
import { Inbox } from "../models/inboxModel.ts";
|
import { Inbox } from "../models/inboxModel.ts";
|
||||||
|
|
||||||
export interface IConfig extends IConfigRemovedOptions {
|
export interface IConfig {
|
||||||
mongodbUrl: string;
|
mongodbUrl: string;
|
||||||
logger: {
|
logger: {
|
||||||
files: boolean;
|
files: boolean;
|
||||||
@ -123,11 +123,7 @@ export const configRemovedOptionsKeys = [
|
|||||||
"flawlessRelicsAlwaysGiveSilverReward",
|
"flawlessRelicsAlwaysGiveSilverReward",
|
||||||
"radiantRelicsAlwaysGiveGoldReward",
|
"radiantRelicsAlwaysGiveGoldReward",
|
||||||
"disableDailyTribute"
|
"disableDailyTribute"
|
||||||
] as const;
|
];
|
||||||
|
|
||||||
type IConfigRemovedOptions = {
|
|
||||||
[K in (typeof configRemovedOptionsKeys)[number]]?: boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const configPath = path.join(repoDir, args.configPath ?? "config.json");
|
export const configPath = path.join(repoDir, args.configPath ?? "config.json");
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,13 @@
|
|||||||
import chokidar from "chokidar";
|
import chokidar from "chokidar";
|
||||||
import { logger } from "../utils/logger.ts";
|
import { logger } from "../utils/logger.ts";
|
||||||
import { config, configPath, configRemovedOptionsKeys, loadConfig, syncConfigWithDatabase } from "./configService.ts";
|
import {
|
||||||
|
config,
|
||||||
|
configPath,
|
||||||
|
configRemovedOptionsKeys,
|
||||||
|
loadConfig,
|
||||||
|
syncConfigWithDatabase,
|
||||||
|
type IConfig
|
||||||
|
} from "./configService.ts";
|
||||||
import { saveConfig, shouldReloadConfig } from "./configWriterService.ts";
|
import { saveConfig, shouldReloadConfig } from "./configWriterService.ts";
|
||||||
import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts";
|
import { getWebPorts, startWebServer, stopWebServer } from "./webService.ts";
|
||||||
import { sendWsBroadcast } from "./wsService.ts";
|
import { sendWsBroadcast } from "./wsService.ts";
|
||||||
@ -35,9 +42,11 @@ chokidar.watch(configPath).on("change", () => {
|
|||||||
export const validateConfig = (): void => {
|
export const validateConfig = (): void => {
|
||||||
let modified = false;
|
let modified = false;
|
||||||
for (const key of configRemovedOptionsKeys) {
|
for (const key of configRemovedOptionsKeys) {
|
||||||
if (config[key] !== undefined) {
|
if (config[key as keyof IConfig] !== undefined) {
|
||||||
logger.debug(`Spotted removed option ${key} with value ${config[key]} in config.json.`);
|
logger.debug(
|
||||||
delete config[key];
|
`Spotted removed option ${key} with value ${String(config[key as keyof IConfig])} in config.json.`
|
||||||
|
);
|
||||||
|
delete config[key as keyof IConfig];
|
||||||
modified = true;
|
modified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user