|
11 months ago | |
---|---|---|
.. | ||
index.js | 11 months ago | |
license | 11 months ago | |
package.json | 11 months ago | |
readme.md | 11 months ago |
Get namespaced config from the closest package.json
Having tool specific config in package.json reduces the amount of metafiles in your repo (there are usually a lot!) and makes the config obvious compared to hidden dotfiles like .jshintrc
, which can end up causing confusion. XO, for example, use the xo
namespace in package.json, and ESLint uses eslintConfig
. Many more tools supports this, like AVA, Babel, nyc, etc.
$ npm install --save pkg-conf
{
"name": "some-package",
"version": "1.0.0",
"unicorn": {
"rainbow": true
}
}
const pkgConf = require('pkg-conf');
pkgConf('unicorn').then(config => {
console.log(config.rainbow);
//=> true
});
It walks up parent directories until a package.json
can be found, reads it, and returns the user specified namespace or an empty object if not found.
Returns a promise that resolves to the config.
Returns the config.
Type: string
The package.json namespace you want.
Type: string
Default: process.cwd()
Directory to start looking up for a package.json file.
Type: Object
Default config.
Pass in the config
returned from any of the above methods.
Returns the filepath to the package.json file or null
.
MIT © Sindre Sorhus