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

19 lines
643 B
TypeScript
Raw Normal View History

2023-10-07 17:01:16 -04:00
import {readFileSync} from 'node:fs';
import {Config} from '../typings/interfaces';
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-10-08 18:03:17 -04:00
static readConfig() {
return JSON.parse(readFileSync(process.argv[2] ?? 'src/config.json', 'utf8')) as Config;
}
}