1.1.2 • Published 7 years ago
oniyi-config v1.1.2
oniyi-config

Simple config file loader
Installation
$ npm install --save oniyi-configUsage
const oniyiConfig = require('oniyi-config');
const cfg = oniyiConfig({
sourceDir: __dirname,
baseName: 'providers',
environment: 'production',
});will merge jsand json files starting with name providers in __dirname
iteratively. File name schema is providers.[environment].(json|js).
environment is optional and defaults to development. Possible values are anything you can set in process.env.NODE_ENV. For file name resolution, process.env.NODE_ENV will be transformed to lower-case.
One special environment is local. It will always be loaded last. You can provide the same file name with different extensions. json will always be loaded before js, meaning js will overwrite json
Sample load order: 1. providers.json 2. providers.js 3. providers.development.json 4. providers.development.js 5. providers.local.json 6. providers.local.js
Options
- sourceDir, baseDir, basePath: single directory path to load config files from
- sourceDirs: array of directory paths to load config files from. Files are loaded in preceding order (meaning the last one is loaded first extended with
_.mergeWith()in reverse order; ascustomizerfor_.mergeWith(), a custom function fromlib/utils.jsis used) - baseName: the baseName for config files (e.g.
providersfrom the example above) - env, environment: the
environmentpart of config file names (e.g.developmentfrom the example above) Note:localis always added / loaded
License
MIT © Benjamin Kroeger