Last active
January 25, 2018 20:57
-
-
Save wmantly/1283bbffca25d92bc0b84dac106b1e9c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 'use strict'; | |
| const app = require('../app'); | |
| const extend = require('extend'); | |
| function load(filePath, required){ | |
| try { | |
| return require(filePath); | |
| } catch(error){ | |
| if(error.name === 'SyntaxError'){ | |
| console.error(`Loading ${filePath} file failed!\n`, error.message); | |
| process.exit(1); | |
| } else if (error.code === 'MODULE_NOT_FOUND'){ | |
| console.warn(`NO ${filePath} FILE FOUND! This may cause issues...`); | |
| if (required){ | |
| process.exit(1); | |
| } | |
| return {}; | |
| }else{ | |
| console.dir(`Unknown error in loading ${filePath} config file.\n`, error); | |
| } | |
| } | |
| }; | |
| module.exports = extend( | |
| true, // enable deep copy | |
| load('./default', true), | |
| load(`./${app.locals.settings.env}`), | |
| load('./secrets') | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment