UNPKG

1.21 kBMarkdownView Raw
1# matchdep [![Build Status](https://secure.travis-ci.org/tkellen/node-matchdep.png?branch=master)](http://travis-ci.org/tkellen/node-matchdep)
2
3> Use minimatch to filter npm module dependencies by name.
4
5## Examples
6
7```js
8var matchdep = require('matchdep');
9
10// Filter dependencies (with autoloading of package.json from cwd)
11matchdep.filter('mini*');
12
13// Filter devDependencies (with config string indicating file to be required)
14matchdep.filterDev('grunt-contrib-*', './package.json');
15
16// Filter peerDependencies (with config string indicating file to be required)
17matchdep.filterDev('foo-{bar,baz}', './some-other.json');
18
19// Filter all dependencies (with explicit config provided)
20matchdep.filterAll('*', require('./yet-another.json'));
21```
22
23## Usage
24
25```js
26filter(pattern, config)
27filterDev(pattern, config)
28filterPeer(pattern, config)
29filterAll(pattern, config)
30```
31
32### pattern
33Type: `String`
34Default: none
35
36[minimatch](https://github.com/isaacs/minimatch) compatible pattern to filter dependencies.
37
38### config
39Type: `String` or `Object`
40Default: `path.resolve(process.cwd(), 'package.json')`
41
42If config is a string, matchdep will attempt to require it. If it is an object, it will be used directly.