Skip to content

Latest commit

 

History

History
68 lines (49 loc) · 1.64 KB

.verb.md

File metadata and controls

68 lines (49 loc) · 1.64 KB

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('{%= name %}');
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