nollup
nollup copied to clipboard
Use cosmiconfig to read config
Some advantages:
This would add support for more ways to configure nollup:
- a
nollup
property inpackage.json
- a
.nolluprc
file in JSON or YAML format - a
.nolluprc.json
file - a
.nolluprc.yaml
,.nolluprc.yml
, or.nolluprc.js
file - a
nollup.config.js
file exporting a JS object
It is widely adapted; used by 3.3m github repositories.
It has a documented order in which it will look for configuration.
Starting from process.cwd()
it will look for:
- a
package.json
property - a
JSON
orYAML
, extensionless "rc file" - an "rc file" with the extensions
.json
,.yaml
,.yml
, or.js
. - a
.config.js
CommonJS module
This should be backwards compatible with the current implementation where the .nolluprc
file has precedence over the nolluprc.js
file:
https://github.com/PepsRyuu/nollup/blob/1411a03ea3f63a2d398cc3416bdb9566b11056ce/lib/cli.js#L93-L97
Is there a specific reason the current implementation loads the configuration synchronously (i.e. using
fs.existsSync
andfs.readFileSync
)?
Could be replaced with
const cosmiconfigResult = require('cosmiconfig').cosmiconfigSync('nollup').search();
if (cosmiconfigResult && cosmiconfigResult.config) {
options = Object.assign({}, options, cosmiconfigResult.config);
}
cosmiconfig can be used synchronously as well as asynchronously.
See https://github.com/davidtheclark/cosmiconfig for more information.