config-finder
v1.0.3
Published
Autoload config for a specific module
Downloads
5
Readme
config-finder
Find and load a configuration object. based on cosmiconfig
Installation
npm i config-finder
Features
- Support functionaly evaluation with customize context.
- Mixin multiple externals by
extends
property.
Usage
// cat package.json
{
...
"fss": {
"extends": [
"./.fssrc.js"
],
"foo": [ "bar" ]
}
}
// cat ./.fssrc.js
module.exports = (ctx) => {
return Object.assign({}, ctx,
{
rollup: { /* input, output */ }
}
}
const configFinder = require('config-finder')
const yourModuleName = 'fss'
const modConfig = configFinder(yourModuleName)
const cfg = modConfig(ctx[, path, options])
.then((result) => {
// result.config is the parsed configuration object
// result.filepath is the path to the config file that was found
})
.catch((parsingError) => {
// do something constructive
});
// sync mode
// const cfg = modConfig.sync(ctx[, path, options])