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'));
|
2023-10-07 17:09:30 -04:00
|
|
|
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');
|
2023-10-07 17:09:30 -04:00
|
|
|
}
|