Remove CONFIG_PATH env var

This commit is contained in:
Isaac 2022-07-21 14:30:03 +01:00
parent f93d058f55
commit 3a9483dbfb
No known key found for this signature in database
GPG Key ID: F4EAABEB0FFCC06A
2 changed files with 5 additions and 7 deletions

View File

@ -1,8 +1,8 @@
CONFIG_PATH=./user/config.yml
DISCORD_SECRET= DISCORD_SECRET=
DISCORD_TOKEN= DISCORD_TOKEN=
DB_CONNECTION_URL="mysql://test:password@localhost/tickets0" DB_CONNECTION_URL="mysql://test:password@localhost/tickets0"
ENCRYPTION_KEY= ENCRYPTION_KEY=
HTTP_BIND=8080 HTTP_BIND=8080
HTTP_EXTERNAL=http://localhost:8080 HTTP_EXTERNAL=http://localhost:8080
PORTAL=http://localhost:3000
SUPER= SUPER=

View File

@ -46,23 +46,21 @@ if (process.env.ENCRYPTION_KEY === undefined) {
process.exit(1); process.exit(1);
} }
process.env.CONFIG_PATH ??= './user/config.yml'; // set default config file path if (!fs.existsSync('./user/config.yml')) {
if (!fs.existsSync(process.env.CONFIG_PATH)) {
const examplePath = './user/example.config.yml'; const examplePath = './user/example.config.yml';
if (!fs.existsSync(examplePath)) { if (!fs.existsSync(examplePath)) {
console.log('\x07' + colours.redBright('The config file does not exist, and the example file is missing so cannot be copied from.')); console.log('\x07' + colours.redBright('The config file does not exist, and the example file is missing so cannot be copied from.'));
process.exit(1); process.exit(1);
} else { } else {
console.log('Creating config file...'); console.log('Creating config file...');
fs.copyFileSync(examplePath, process.env.CONFIG_PATH); fs.copyFileSync(examplePath, './user/config.yml');
console.log(`Copied config to ${process.env.CONFIG_PATH}`); console.log(`Copied config to ${'./user/config.yml'}`);
} }
} }
console.log(banner(pkg.version)); // print big title console.log(banner(pkg.version)); // print big title
const config = YAML.parse(fs.readFileSync(process.env.CONFIG_PATH, 'utf8')); const config = YAML.parse(fs.readFileSync('./user/config.yml', 'utf8'));
const log = logger(config); const log = logger(config);
process.on('unhandledRejection', error => { process.on('unhandledRejection', error => {