1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-11-18 17:00:58 -05:00
Daggerbot-TS/src/helpers/ConfigHelper.ts

18 lines
692 B
TypeScript
Raw Normal View History

2023-10-07 17:01:16 -04:00
import {readFileSync} from 'node:fs';
2023-12-24 10:21:40 -05:00
import {Config} from '../interfaces';
2023-10-07 17:01:16 -04:00
export default class ConfigHelper {
2023-10-08 18:03:17 -04:00
static loadConfig() {
2023-10-07 17:01:16 -04:00
let importconfig:Config;
try {
2023-10-08 18:03:17 -04:00
importconfig = JSON.parse(readFileSync(process.argv[2] ?? 'src/config.json', 'utf8'));
console.log(`Loaded the config :: ${importconfig.configName}`);
2023-10-07 17:01:16 -04:00
} catch (e) {
2023-10-08 18:03:17 -04:00
console.error(`Error loading config file "${process.argv[2] ?? 'src/config.json'}": ${e}`);
2023-10-07 17:01:16 -04:00
process.exit(1);
}
return importconfig;
}
2023-12-24 10:21:40 -05:00
static readConfig =()=>JSON.parse(readFileSync(process.argv[2] ?? 'src/config.json', 'utf8')) as Config;
static isDevMode =()=>this.readConfig().configName.includes('Beta');
}