Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonschlinkert/merge-configs

Find, load and merge JSON and YAML config settings from one or more files, in the specified order.
https://github.com/jonschlinkert/merge-configs

combine conf config configuration data eslint find jonschlinkert lookup merge namespace node nodejs object package rc runtime-config search store

Last synced: about 1 month ago
JSON representation

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

Awesome Lists containing this project

README

        

# merge-configs [![NPM version](https://img.shields.io/npm/v/merge-configs.svg?style=flat)](https://www.npmjs.com/package/merge-configs) [![NPM monthly downloads](https://img.shields.io/npm/dm/merge-configs.svg?style=flat)](https://npmjs.org/package/merge-configs) [![NPM total downloads](https://img.shields.io/npm/dt/merge-configs.svg?style=flat)](https://npmjs.org/package/merge-configs) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/merge-configs.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/merge-configs)

> 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](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.

## Install

Install with [npm](https://www.npmjs.com/):

```sh
$ 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

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

## options

### options.builtins

**Type**: `boolean`

**Default**: `undefined`

Disable built-in loaders.

```js
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.

```js
// 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](#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](#options)

## About

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).

Please read the [contributing guide](.github/contributing.md) 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:

```sh
$ npm install && npm test
```

Building docs

_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_

To generate the readme, run the following command:

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

### Author

**Jon Schlinkert**

* [GitHub Profile](https://github.com/jonschlinkert)
* [Twitter Profile](https://twitter.com/jonschlinkert)
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)

### License

Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
Released under the [MIT License](LICENSE).

***

_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on November 19, 2018._