Socket
Book a DemoInstallSign in
Socket

merge-configs

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

merge-configs

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

latest
Source
npmnpm
Version
3.0.0
Version published
Maintainers
1
Created
Source

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

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.

Keywords

configs

FAQs

Package last updated on 19 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts