function init(pathToConfig) { nconf.argv() .env(); if (pathToConfig) { nconf.file(pathToConfig); } return { publish: (...args) => {return publish(...args)} } }
const loadSettings = ({ appSettingsPath }) => new Promise((resolve, reject) => { try { if (_.isEmpty(appSettingsPath)) { throw new Error('Configuration settings path is required.'); } nconf.file({ file: appSettingsPath, // Setting the separator as dot for nested objects logicalSeparator: '.', }); resolve(); } catch (err) { reject(err); } })
// // utility method to reload the file based stores so // the last one added is on the top of the files hierarchy // unless the bottom flag indicates to add otherwise // reorderFileStores(path, bottom) { // first remove all the file stores for (const x in this._fileStores) { this._config.remove(this._fileStores[x]); } if (bottom) { // add to the bottom of the list this._fileStores.push(path); } else { // add this new file to the front of the list this._fileStores.unshift(path); } // now load all the file stores for (const x in this._fileStores) { const name = this._fileStores[x]; this._config.file(name, name); } }
// // utility method to reload the file based stores so // the last one added is on the top of the files hierarchy // unless the bottom flag indicates to add otherwise // reorderFileStores(path, bottom) { // first remove all the file stores for (const x in this._fileStores) { this._config.remove(this._fileStores[x]); } if (bottom) { // add to the bottom of the list this._fileStores.push(path); } else { // add this new file to the front of the list this._fileStores.unshift(path); } // now load all the file stores for (const x in this._fileStores) { const name = this._fileStores[x]; this._config.file(name, name); } }