nconf-lite/lib/nconf.js

41 lines
994 B
JavaScript
Raw Normal View History

/*
* nconf.js: Top-level include for the nconf module
*
* (C) 2011, Nodejitsu Inc.
*
*/
2011-08-23 10:53:05 +00:00
var fs = require('fs'),
async = require('async'),
common = require('./nconf/common'),
2011-08-23 10:53:05 +00:00
Provider = require('./nconf/provider').Provider,
nconf = module.exports = new Provider();
2011-05-17 02:44:46 +00:00
//
2013-12-02 06:21:21 +00:00
// Expose the version from the package.json
2011-05-17 02:44:46 +00:00
//
2013-12-02 06:21:21 +00:00
nconf.version = require('../package.json').version;
2011-04-19 21:34:42 +00:00
//
// Setup all stores as lazy-loaded getters.
//
fs.readdirSync(__dirname + '/nconf/stores').forEach(function (file) {
var store = file.replace('.js', ''),
name = common.capitalize(store);
2012-04-14 19:28:55 +00:00
nconf.__defineGetter__(name, function () {
return require('./nconf/stores/' + store)[name];
});
});
//
// Expose the various components included with nconf
//
nconf.key = common.key;
nconf.path = common.path;
nconf.loadFiles = common.loadFiles;
nconf.loadFilesSync = common.loadFilesSync;
nconf.formats = require('./nconf/formats');
nconf.Provider = Provider;
2013-12-02 06:21:21 +00:00