merge-configs
Find, load and merge JSON and YAML config settings from one or more files, in the specified order.
Last updated 2 years ago by jonschlinkert .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install merge-configs 
SYNC missed versions from official npm registry.

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 :heart: 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

<summary> Contributing</summary>

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.

<summary> Running Tests</summary>

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
<summary> Building docs</summary>

(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.

Current Tags

  • 3.0.0                                ...           latest (2 years ago)

3 Versions

  • 3.0.0                                ...           2 years ago
  • 2.0.0                                ...           3 years ago
  • 1.0.0                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 6
Last Day 0
Last Week 6
Last Month 1
Dependencies (1)
Dev Dependencies (4)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |