2011-11-24 02:48:33 +00:00
|
|
|
/*
|
2015-07-07 20:06:41 +00:00
|
|
|
* nconf-hierarchical-load-save.js: Test fixture for using yargs, envvars and a file store with nconf.
|
2011-11-24 02:48:33 +00:00
|
|
|
*
|
2014-11-26 06:31:48 +00:00
|
|
|
* (C) 2011, Charlie Robbins and the Contributors.
|
2011-11-24 02:48:33 +00:00
|
|
|
*
|
|
|
|
*/
|
2014-11-26 06:31:48 +00:00
|
|
|
|
2017-10-21 20:01:01 +00:00
|
|
|
var path = require('path'),
|
2011-11-24 02:48:33 +00:00
|
|
|
nconf = require('../../../lib/nconf');
|
|
|
|
|
|
|
|
//
|
2014-11-26 06:31:48 +00:00
|
|
|
// Setup nconf to use (in-order):
|
2011-11-24 02:48:33 +00:00
|
|
|
// 1. Command-line arguments
|
|
|
|
// 2. Environment variables
|
|
|
|
// 3. A file located at 'path/to/config.json'
|
|
|
|
//
|
|
|
|
nconf.argv()
|
|
|
|
.env()
|
|
|
|
.file({ file: path.join(__dirname, '..', 'load-save.json') });
|
|
|
|
|
|
|
|
//
|
|
|
|
// Set a few variables on `nconf`.
|
|
|
|
//
|
|
|
|
nconf.set('database:host', '127.0.0.1');
|
|
|
|
nconf.set('database:port', 5984);
|
|
|
|
|
|
|
|
process.stdout.write(nconf.get('foo'));
|
|
|
|
//
|
|
|
|
// Save the configuration object to disk
|
|
|
|
//
|
2015-07-07 20:06:41 +00:00
|
|
|
nconf.save();
|