multimatch
Advanced tools
Comparing version 2.0.0 to 2.1.0
17
index.js
'use strict'; | ||
var minimatch = require('minimatch'); | ||
var union = require('array-union'); | ||
var diff = require('array-differ'); | ||
var arrayUnion = require('array-union'); | ||
var arrayDiffer = require('array-differ'); | ||
var arrify = require('arrify'); | ||
function arrayify(arr) { | ||
return Array.isArray(arr) ? arr : [arr]; | ||
} | ||
module.exports = function (list, patterns, options) { | ||
list = arrayify(list); | ||
patterns = arrayify(patterns); | ||
list = arrify(list); | ||
patterns = arrify(patterns); | ||
@@ -21,7 +18,7 @@ if (list.length === 0 || patterns.length === 0) { | ||
return patterns.reduce(function (ret, pattern) { | ||
var process = union; | ||
var process = arrayUnion; | ||
if (pattern[0] === '!') { | ||
pattern = pattern.slice(1); | ||
process = diff; | ||
process = arrayDiffer; | ||
} | ||
@@ -28,0 +25,0 @@ |
{ | ||
"name": "multimatch", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Extends minimatch.match() with support for multiple patterns", | ||
@@ -8,4 +8,4 @@ "license": "MIT", | ||
"author": { | ||
"email": "sindresorhus@gmail.com", | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
@@ -29,13 +29,13 @@ }, | ||
"keywords": [ | ||
"minimatch", | ||
"expand", | ||
"find", | ||
"glob", | ||
"globbing", | ||
"globs", | ||
"match", | ||
"matcher", | ||
"minimatch", | ||
"pattern", | ||
"patterns", | ||
"glob", | ||
"globs", | ||
"globbing", | ||
"expand", | ||
"wildcard", | ||
"find" | ||
"wildcard" | ||
], | ||
@@ -45,8 +45,9 @@ "dependencies": { | ||
"array-union": "^1.0.1", | ||
"minimatch": "^2.0.1" | ||
"arrify": "^1.0.0", | ||
"minimatch": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.9.1", | ||
"chai": "^3.4.1", | ||
"mocha": "*" | ||
} | ||
} |
@@ -30,3 +30,16 @@ # multimatch [![Build Status](https://travis-ci.org/sindresorhus/multimatch.svg?branch=master)](https://travis-ci.org/sindresorhus/multimatch) | ||
```js | ||
var results = multimatch(paths, patterns); | ||
``` | ||
The return value is an array of matching paths. | ||
## How multiple patterns work | ||
Positive patterns (e.g. `foo` or `*`) add to the results, while negative patterns (e.g. `!foo`) subtract from the results. | ||
Therefore a lone negation (e.g. `['!foo']`) will never match anything – use `['*', '!foo']` instead. | ||
## Globbing patterns | ||
@@ -33,0 +46,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4403
4
63
4
21
+ Addedarrify@^1.0.0
+ Addedarrify@1.0.1(transitive)
+ Addedminimatch@3.1.2(transitive)
- Removedminimatch@2.0.10(transitive)
Updatedminimatch@^3.0.0