merge-configs

3.0.0 • Public • Published

merge-configs NPM version NPM monthly downloads NPM total downloads Linux Build Status

Find, load and merge JSON and YAML config settings from one or more files, in the specified order.

Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your ❤️ and support.

Install

Install with npm:

$ npm install --save merge-configs

What does this do?

This library makes it easy for your application to support config files similar to .eslintrc.json, .travis.yml, etc. by providing granular control over:

  • the patterns and directories to search for config files
  • how config files are loaded (or whether or not they should be loaded at all)
  • which config files are merged, and how they are merged

Usage

const configs = require('merge-configs');
console.log(configs(name[, locations, options]));

options

options.builtins

Type: boolean

Default: undefined

Disable built-in loaders.

const mergeConfig = new MergeConfig({
  options: {
    builtins: false
  }  
});

options.filter

Type: function

Default: undefined

Filter files that are resolved by glob patterns. Useful for conditionally filtering out files based on contents or other variables.

// can be defined on the ctor options
const mergeConfig = new MergeConfig({
  options: {
    filter: file => {
      // "file" is an object with path properties
      return file.basename === 'foo.json'
    }
  }  
});
 
// or on the options for a specific config type
mergeConfig.type('local', {
  cwd: process.cwd(),
  patterns: ['*.json'],
  filter: file => {
    return file.basename !== 'foo.json';
  }
});

Params

  • name {String} - (required) The module name (example: eslint, babel, travis etc)
  • types {Array} - (optional) The config locations or "types" to search. If specified, only the given locations will be searched. If undefined, all locations are searched.
  • options {Object} - see all available options

About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.

Please read the contributing guide for advice on opening issues, pull requests, and coding standards.

Running Tests

Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:

$ npm install && npm test
Building docs

(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)

To generate the readme, run the following command:

$ npm install -g verbose/verb#dev verb-generate-readme && verb

Author

Jon Schlinkert

License

Copyright © 2018, Jon Schlinkert. Released under the MIT License.


This file was generated by verb-generate-readme, v0.8.0, on November 19, 2018.

Readme

Keywords

Package Sidebar

Install

npm i merge-configs

Weekly Downloads

2

Version

3.0.0

License

MIT

Unpacked Size

14.6 kB

Total Files

4

Last publish

Collaborators

  • jonschlinkert