mirror of
https://github.com/edumeet/edumeet.git
synced 2026-01-23 02:34:58 +00:00
changed config path resolution and displaying debug infos about path locations
This commit is contained in:
parent
167f4fdb8b
commit
cffc384c8f
2 changed files with 9 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import convict from 'convict';
|
||||
import { ipaddress, url } from 'convict-format-with-validator';
|
||||
import json5 from 'json5';
|
||||
|
|
@ -484,7 +485,7 @@ let configLoaded = false;
|
|||
// Load config from file
|
||||
for (const format of [ 'json', 'json5', 'yaml', 'yml', 'toml' ]) // eslint-disable-line no-restricted-syntax
|
||||
{
|
||||
const filepath = `./config/config.${format}`;
|
||||
const filepath = path.normalize(`${__dirname}/../config/config.${format}`);
|
||||
|
||||
if (fs.existsSync(filepath))
|
||||
{
|
||||
|
|
@ -504,7 +505,7 @@ for (const format of [ 'json', 'json5', 'yaml', 'yml', 'toml' ]) // eslint-disab
|
|||
|
||||
if (!configLoaded)
|
||||
{
|
||||
logger.warn('No config file found, using defaults.');
|
||||
logger.warn(`No config file found in ${path.normalize(`${__dirname}/../config/`)}, using defaults.`);
|
||||
configSchema.load({});
|
||||
}
|
||||
|
||||
|
|
@ -520,17 +521,19 @@ catch (error: any)
|
|||
}
|
||||
|
||||
// load additional config module (no validation is performed)
|
||||
if (fs.existsSync(`${__dirname}/../config/config.js`))
|
||||
const configModuleFilepath = path.normalize(`${__dirname}/../config/config.js`);
|
||||
if (fs.existsSync(configModuleFilepath))
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.info(`Loading config module from ${configModuleFilepath}`);
|
||||
const configModule = require('../config/config.js'); // eslint-disable-line @typescript-eslint/no-var-requires
|
||||
|
||||
Object.assign(config, configModule);
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
logger.error(`Error loading ${config.configFile} module: ${err.message}`);
|
||||
logger.error(`Error loading ${configModuleFilepath} module: ${err.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
"**/*.js"
|
||||
],
|
||||
"exclude": [
|
||||
"./public"
|
||||
"./public",
|
||||
"./dist"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue