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