diff --git a/src/globals.js b/src/globals.js index 22048703..666722c5 100755 --- a/src/globals.js +++ b/src/globals.js @@ -63,7 +63,7 @@ let configFileOption; let configFileExpanded; let configFilePath; let configFileBasename; -let configFileExtension = 'yaml'; +let configFileExtension = '.yaml'; if (options.configfile && options.configfile.length > 0) { configFileOption = options.configfile; configFileExpanded = path.resolve(options.configfile); @@ -85,12 +85,21 @@ if (options.configfile && options.configfile.length > 0) { console.log('Error: Specified config file does not exist'); process.exit(1); } +} else { + // Set default values of environment variables controlling config file location and name + if (process.env.NODE_CONFIG_DIR === undefined) { + process.env.NODE_CONFIG_DIR = path.join(process.cwd(), 'config'); + } + + if (process.env.NODE_ENV === undefined) { + process.env.NODE_ENV = 'production'; + } } -// Set global variable conttaining the name and full pathof the config file +// Set global variable conttaining the name and full path of the config file const configFile = path.join( process.env.NODE_CONFIG_DIR, - process.env.NODE_ENV + configFileExtension + `${process.env.NODE_ENV}${configFileExtension}` ); // Are we running as standalone app or not? @@ -148,6 +157,13 @@ const logger = winston.createLogger({ ), }); +// Show contents of environment variables controlling config file location and name +logger.debug(`NODE_CONFIG_DIR: ${process.env.NODE_CONFIG_DIR}`); +logger.debug(`NODE_ENV: ${process.env.NODE_ENV}`); + +// Output config file name and path to log +logger.info(`Using config file: ${configFile}`); + // Function to get current logging level const getLoggingLevel = () => logTransports.find((transport) => transport.name === 'console').level;