load-config-folder
Load the config from folder as a plain object.
- The config file format can be registered.
- The registered file format order is the search order.
- the virtual file system can be specfied:
loadConfig.setFileSystem(fs)
fs.path = require('path.js/lib/path').path
for the virtual POSIX path.- you must set the path first before call setFileSystem.
The load-config-folder
is similar to the load-config-file.
But it will load the configuration from the folder with a specified file name, you can use addConfig
to set the specified config file name(it's a basename
).
Usage
var loadConfig = ;var yaml = ;var cson = ; //the config file basename for the folder.loadConfig;loadConfig;loadConfig;loadConfig; //Synchronously load config for the folder.//it will search folder/_config.yaml, folder/_config.yml, folder/_config.cson, folder/_config.json//the first exist file will be loaded.//the default encoding is "utf8" if no encoding.//loadConfig('config', {encoding: 'ascii'})//the non-enumerable "$cfgPath" property added.console; //Asynchronously load config from file
API
var config = ;
config.setFileSystem(fs)
: set your favour file system. defaults to 'fs'.- the "file system" must implement
readFile(path[, options], done)
andreadFileSync(path[, options])
- the "file system" must implement
load(dir, options, done)
: Asynchronously load config from dir- return the plain object and the
$cfgPath
property added if suceesful.
- return the plain object and the
loadSync(dir, options)
: Synchronously load config from dir- return the plain object and the
$cfgPath
property added if suceesful.
- return the plain object and the
License
MIT