How to use the formats function from nconf

Find comprehensive JavaScript nconf.formats code examples handpicked from public code repositorys.

190
191
192
193
194
195
196
197
198
199
200
 * Returns the settings for parsing a configuration file.
 * @param {string} filename The path of the configuration file.
 * @return {{file: string, logicalSeparator: string, format: object}} The parsing options.
 */
function getFileParsingOptions(filename) {
    return { file: filename, logicalSeparator: '-', format: nconf.formats.yaml };
}


/**
 * Creates an absolute path from the provided relative path if necessary.
fork icon0
star icon0
watch icon1

+ 10 other calls in file

176
177
178
179
180
181
182
183
184
185
if (filePath.endsWith('.js')) {  // JS file
  const conf = require(filePath);
  store.use(scope, { type: 'literal', store: conf });
} else {   // JSON or YAML
  const options = { file: filePath }
  if (filePath.endsWith('.yml') || filePath.endsWith('.yaml')) { options.format = nconf.formats.yaml }
  store.file(scope, options);
}

logger.debug('Loaded [' + scope + '] from file: ' + filePath)
fork icon0
star icon0
watch icon0