nconf-lite/lib/nconf.js

40 lines
997 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
//
// Expose the version from the package.json using `pkginfo`.
2011-05-17 02:44:46 +00:00
//
2011-06-08 03:45:01 +00:00
require('pkginfo')(module, '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;