2011-03-31 06:32:47 +00:00
|
|
|
/*
|
|
|
|
* nconf.js: Top-level include for the nconf module
|
|
|
|
*
|
2011-11-24 05:33:08 +00:00
|
|
|
* (C) 2011, Nodejitsu Inc.
|
2011-03-31 06:32:47 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-08-23 10:53:05 +00:00
|
|
|
var fs = require('fs'),
|
|
|
|
async = require('async'),
|
2011-08-28 12:50:26 +00:00
|
|
|
common = require('./nconf/common'),
|
2011-08-23 10:53:05 +00:00
|
|
|
Provider = require('./nconf/provider').Provider,
|
2011-09-16 10:49:47 +00:00
|
|
|
nconf = module.exports = new Provider();
|
2011-05-17 02:44:46 +00:00
|
|
|
|
|
|
|
//
|
2011-06-05 05:39:39 +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
|
|
|
|
2011-11-23 02:22:09 +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
|
|
|
|
2011-11-23 02:22:09 +00:00
|
|
|
nconf.__defineGetter__(name, function () {
|
|
|
|
return require('./nconf/stores/' + store)[name];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2011-04-02 07:03:16 +00:00
|
|
|
//
|
2011-05-14 05:47:26 +00:00
|
|
|
// Expose the various components included with nconf
|
2011-04-02 23:17:04 +00:00
|
|
|
//
|
2011-09-16 10:49:47 +00:00
|
|
|
nconf.key = common.key;
|
|
|
|
nconf.path = common.path;
|
|
|
|
nconf.loadFiles = common.loadFiles;
|
|
|
|
nconf.loadFilesSync = common.loadFilesSync;
|
|
|
|
nconf.formats = require('./nconf/formats');
|
2011-11-23 02:22:09 +00:00
|
|
|
nconf.Provider = Provider;
|