micromatch 4.0.2 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of micromatch might be problematic. Click here for more details.
- package/README.md +73 -62
- package/index.js +14 -14
- package/package.json +8 -7
- package/CHANGELOG.md +0 -108
package/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# micromatch [](https://www.npmjs.com/package/micromatch) [](https://npmjs.org/package/micromatch) [](https://npmjs.org/package/micromatch) [](https://github.com/micromatch/micromatch/actions/workflows/test.yml)
|
2
2
|
|
3
3
|
> Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.
|
4
4
|
|
@@ -54,7 +54,7 @@ Please consider following this project's author, [Jon Schlinkert](https://github
|
|
54
54
|
|
55
55
|
## Install
|
56
56
|
|
57
|
-
Install with [npm](https://www.npmjs.com/):
|
57
|
+
Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=8.6):
|
58
58
|
|
59
59
|
```sh
|
60
60
|
$ npm install --save micromatch
|
@@ -93,7 +93,7 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
|
|
93
93
|
* More complete support for the Bash 4.3 specification than minimatch and multimatch. Micromatch passes _all of the spec tests_ from bash, including some that bash still fails.
|
94
94
|
* **Fast & Performant** - Loads in about 5ms and performs [fast matches](#benchmarks).
|
95
95
|
* **Glob matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories
|
96
|
-
* **[Advanced globbing](#
|
96
|
+
* **[Advanced globbing](#extended-globbing)** - Supports [extglobs](#extglobs), [braces](#braces-1), and [POSIX brackets](#posix-bracket-expressions), and support for escaping special characters with `\` or quotes.
|
97
97
|
* **Accurate** - Covers more scenarios [than minimatch](https://github.com/yarnpkg/yarn/pull/3339)
|
98
98
|
* **Well tested** - More than 5,000 [test assertions](./test)
|
99
99
|
* **Windows support** - More reliable windows support than minimatch and multimatch.
|
@@ -103,7 +103,7 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
|
|
103
103
|
|
104
104
|
* Support for multiple glob patterns (no need for wrappers like multimatch)
|
105
105
|
* Wildcards (`**`, `*.js`)
|
106
|
-
* Negation (`'!a/*.js'`, `'*!(b).js'
|
106
|
+
* Negation (`'!a/*.js'`, `'*!(b).js'`)
|
107
107
|
* [extglobs](#extglobs) (`+(x|y)`, `!(a|b)`)
|
108
108
|
* [POSIX character classes](#posix-bracket-expressions) (`[[:alpha:][:digit:]]`)
|
109
109
|
* [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
|
@@ -142,9 +142,9 @@ console.log(micromatch(['foo', 'bar', 'baz'], ['f*', '*z'])); //=> ['foo', 'baz'
|
|
142
142
|
|
143
143
|
**Params**
|
144
144
|
|
145
|
-
* **{String|Array<string>}**:
|
146
|
-
* **{String|Array<string>}**:
|
147
|
-
* **{Object}**:
|
145
|
+
* `list` **{String|Array<string>}**: List of strings to match.
|
146
|
+
* `patterns` **{String|Array<string>}**: One or more glob patterns to use for matching.
|
147
|
+
* `options` **{Object}**: See available [options](#options)
|
148
148
|
* `returns` **{Array}**: Returns an array of matches
|
149
149
|
|
150
150
|
**Example**
|
@@ -157,7 +157,7 @@ console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
|
157
157
|
//=> [ 'a.js' ]
|
158
158
|
```
|
159
159
|
|
160
|
-
### [.matcher](index.js#
|
160
|
+
### [.matcher](index.js#L104)
|
161
161
|
|
162
162
|
Returns a matcher function from the given glob `pattern` and `options`. The returned function takes a string to match as its only argument and returns true if the string is a match.
|
163
163
|
|
@@ -178,15 +178,15 @@ console.log(isMatch('a.a')); //=> false
|
|
178
178
|
console.log(isMatch('a.b')); //=> true
|
179
179
|
```
|
180
180
|
|
181
|
-
### [.isMatch](index.js#
|
181
|
+
### [.isMatch](index.js#L123)
|
182
182
|
|
183
183
|
Returns true if **any** of the given glob `patterns` match the specified `string`.
|
184
184
|
|
185
185
|
**Params**
|
186
186
|
|
187
|
-
* **{String}**:
|
188
|
-
* **{String|Array}**:
|
189
|
-
* **{Object}**: See available [options](#options).
|
187
|
+
* `str` **{String}**: The string to test.
|
188
|
+
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
|
189
|
+
* `[options]` **{Object}**: See available [options](#options).
|
190
190
|
* `returns` **{Boolean}**: Returns true if any patterns match `str`
|
191
191
|
|
192
192
|
**Example**
|
@@ -199,7 +199,7 @@ console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
199
199
|
console.log(mm.isMatch('a.a', 'b.*')); //=> false
|
200
200
|
```
|
201
201
|
|
202
|
-
### [.not](index.js#
|
202
|
+
### [.not](index.js#L148)
|
203
203
|
|
204
204
|
Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
205
205
|
|
@@ -220,7 +220,7 @@ console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
|
220
220
|
//=> ['b.b', 'c.c']
|
221
221
|
```
|
222
222
|
|
223
|
-
### [.contains](index.js#
|
223
|
+
### [.contains](index.js#L188)
|
224
224
|
|
225
225
|
Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
|
226
226
|
|
@@ -229,7 +229,7 @@ Returns true if the given `string` contains the given pattern. Similar to [.isMa
|
|
229
229
|
* `str` **{String}**: The string to match.
|
230
230
|
* `patterns` **{String|Array}**: Glob pattern to use for matching.
|
231
231
|
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
|
232
|
-
* `returns` **{Boolean}**: Returns true if the
|
232
|
+
* `returns` **{Boolean}**: Returns true if any of the patterns matches any part of `str`.
|
233
233
|
|
234
234
|
**Example**
|
235
235
|
|
@@ -243,7 +243,7 @@ console.log(mm.contains('aa/bb/cc', '*d'));
|
|
243
243
|
//=> false
|
244
244
|
```
|
245
245
|
|
246
|
-
### [.matchKeys](index.js#
|
246
|
+
### [.matchKeys](index.js#L230)
|
247
247
|
|
248
248
|
Filter the keys of the given object with the given `glob` pattern and `options`. Does not attempt to match nested keys. If you need this feature, use [glob-object](https://github.com/jonschlinkert/glob-object) instead.
|
249
249
|
|
@@ -265,7 +265,7 @@ console.log(mm.matchKeys(obj, '*b'));
|
|
265
265
|
//=> { ab: 'b' }
|
266
266
|
```
|
267
267
|
|
268
|
-
### [.some](index.js#
|
268
|
+
### [.some](index.js#L259)
|
269
269
|
|
270
270
|
Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
|
271
271
|
|
@@ -274,7 +274,7 @@ Returns true if some of the strings in the given `list` match any of the given g
|
|
274
274
|
* `list` **{String|Array}**: The string or array of strings to test. Returns as soon as the first match is found.
|
275
275
|
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
|
276
276
|
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
|
277
|
-
* `returns` **{Boolean}**: Returns true if any patterns
|
277
|
+
* `returns` **{Boolean}**: Returns true if any `patterns` matches any of the strings in `list`
|
278
278
|
|
279
279
|
**Example**
|
280
280
|
|
@@ -288,7 +288,7 @@ console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
|
288
288
|
// false
|
289
289
|
```
|
290
290
|
|
291
|
-
### [.every](index.js#
|
291
|
+
### [.every](index.js#L295)
|
292
292
|
|
293
293
|
Returns true if every string in the given `list` matches any of the given glob `patterns`.
|
294
294
|
|
@@ -297,7 +297,7 @@ Returns true if every string in the given `list` matches any of the given glob `
|
|
297
297
|
* `list` **{String|Array}**: The string or array of strings to test.
|
298
298
|
* `patterns` **{String|Array}**: One or more glob patterns to use for matching.
|
299
299
|
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
|
300
|
-
* `returns` **{Boolean}**: Returns true if
|
300
|
+
* `returns` **{Boolean}**: Returns true if all `patterns` matches all of the strings in `list`
|
301
301
|
|
302
302
|
**Example**
|
303
303
|
|
@@ -315,7 +315,7 @@ console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
|
315
315
|
// false
|
316
316
|
```
|
317
317
|
|
318
|
-
### [.all](index.js#
|
318
|
+
### [.all](index.js#L334)
|
319
319
|
|
320
320
|
Returns true if **all** of the given `patterns` match the specified string.
|
321
321
|
|
@@ -345,7 +345,7 @@ console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
|
345
345
|
// true
|
346
346
|
```
|
347
347
|
|
348
|
-
### [.capture](index.js#
|
348
|
+
### [.capture](index.js#L361)
|
349
349
|
|
350
350
|
Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
|
351
351
|
|
@@ -354,7 +354,7 @@ Returns an array of matches captured by `pattern` in `string, or`null` if the pa
|
|
354
354
|
* `glob` **{String}**: Glob pattern to use for matching.
|
355
355
|
* `input` **{String}**: String to match
|
356
356
|
* `options` **{Object}**: See available [options](#options) for changing how matches are performed
|
357
|
-
* `returns` **{
|
357
|
+
* `returns` **{Array|null}**: Returns an array of captures if the input matches the glob pattern, otherwise `null`.
|
358
358
|
|
359
359
|
**Example**
|
360
360
|
|
@@ -368,7 +368,7 @@ console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
|
368
368
|
//=> null
|
369
369
|
```
|
370
370
|
|
371
|
-
### [.makeRe](index.js#
|
371
|
+
### [.makeRe](index.js#L387)
|
372
372
|
|
373
373
|
Create a regular expression from the given glob `pattern`.
|
374
374
|
|
@@ -388,7 +388,7 @@ console.log(mm.makeRe('*.js'));
|
|
388
388
|
//=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
389
389
|
```
|
390
390
|
|
391
|
-
### [.scan](index.js#
|
391
|
+
### [.scan](index.js#L403)
|
392
392
|
|
393
393
|
Scan a glob pattern to separate the pattern into segments. Used by the [split](#split) method.
|
394
394
|
|
@@ -405,7 +405,7 @@ const mm = require('micromatch');
|
|
405
405
|
const state = mm.scan(pattern[, options]);
|
406
406
|
```
|
407
407
|
|
408
|
-
### [.parse](index.js#
|
408
|
+
### [.parse](index.js#L419)
|
409
409
|
|
410
410
|
Parse a glob pattern to create the source string for a regular expression.
|
411
411
|
|
@@ -419,10 +419,10 @@ Parse a glob pattern to create the source string for a regular expression.
|
|
419
419
|
|
420
420
|
```js
|
421
421
|
const mm = require('micromatch');
|
422
|
-
const state = mm(pattern[, options]);
|
422
|
+
const state = mm.parse(pattern[, options]);
|
423
423
|
```
|
424
424
|
|
425
|
-
### [.braces](index.js#
|
425
|
+
### [.braces](index.js#L446)
|
426
426
|
|
427
427
|
Process the given brace `pattern`.
|
428
428
|
|
@@ -479,7 +479,7 @@ console.log(braces('foo/{a,b,c}/bar', { expand: true }));
|
|
479
479
|
| [onResult](#optionsonResult) | `function` | `undefined` | Function to be called on all items, regardless of whether or not they are matched or ignored. |
|
480
480
|
| `posix` | `boolean` | `false` | Support [POSIX character classes](#posix-bracket-expressions) ("posix brackets"). |
|
481
481
|
| `posixSlashes` | `boolean` | `undefined` | Convert all slashes in file paths to forward slashes. This does not convert slashes in the glob pattern itself |
|
482
|
-
| `prepend` | `
|
482
|
+
| `prepend` | `string` | `undefined` | String to prepend to the generated regex used for matching. |
|
483
483
|
| `regex` | `boolean` | `false` | Use regular expression rules for `+` (instead of matching literal `+`), and for stars that follow closing parentheses or brackets (as in `)*` and `]*`). |
|
484
484
|
| `strictBrackets` | `boolean` | `undefined` | Throw an error if brackets, braces, or parens are imbalanced. |
|
485
485
|
| `strictSlashes` | `boolean` | `undefined` | When true, picomatch won't match trailing slashes with single stars. |
|
@@ -772,7 +772,6 @@ Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`:
|
|
772
772
|
|
773
773
|
* `[ac].js`: matches both `a` and `c`, returning `['a.js', 'c.js']`
|
774
774
|
* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
|
775
|
-
* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
|
776
775
|
* `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']`
|
777
776
|
|
778
777
|
Learn about [regex character classes](http://www.regular-expressions.info/charclass.html).
|
@@ -835,7 +834,7 @@ To solve this, you might be inspired to do something like `'foo\\*'.replace(/\\/
|
|
835
834
|
Install dependencies for running benchmarks:
|
836
835
|
|
837
836
|
```sh
|
838
|
-
$ cd bench && npm install
|
837
|
+
$ cd bench && npm install
|
839
838
|
```
|
840
839
|
|
841
840
|
Run the benchmarks:
|
@@ -846,56 +845,56 @@ $ npm run bench
|
|
846
845
|
|
847
846
|
### Latest results
|
848
847
|
|
849
|
-
As of
|
848
|
+
As of March 24, 2022 (longer bars are better):
|
850
849
|
|
851
850
|
```sh
|
852
851
|
# .makeRe star
|
853
|
-
micromatch x
|
854
|
-
minimatch x
|
852
|
+
micromatch x 2,232,802 ops/sec ±2.34% (89 runs sampled))
|
853
|
+
minimatch x 781,018 ops/sec ±6.74% (92 runs sampled))
|
855
854
|
|
856
855
|
# .makeRe star; dot=true
|
857
|
-
micromatch x 1,
|
858
|
-
minimatch x
|
856
|
+
micromatch x 1,863,453 ops/sec ±0.74% (93 runs sampled)
|
857
|
+
minimatch x 723,105 ops/sec ±0.75% (93 runs sampled)
|
859
858
|
|
860
859
|
# .makeRe globstar
|
861
|
-
micromatch x 1,
|
862
|
-
minimatch x 1,
|
860
|
+
micromatch x 1,624,179 ops/sec ±2.22% (91 runs sampled)
|
861
|
+
minimatch x 1,117,230 ops/sec ±2.78% (86 runs sampled))
|
863
862
|
|
864
863
|
# .makeRe globstars
|
865
|
-
micromatch x 1,
|
866
|
-
minimatch x
|
864
|
+
micromatch x 1,658,642 ops/sec ±0.86% (92 runs sampled)
|
865
|
+
minimatch x 741,224 ops/sec ±1.24% (89 runs sampled))
|
867
866
|
|
868
867
|
# .makeRe with leading star
|
869
|
-
micromatch x 1,
|
870
|
-
minimatch x
|
868
|
+
micromatch x 1,525,014 ops/sec ±1.63% (90 runs sampled)
|
869
|
+
minimatch x 561,074 ops/sec ±3.07% (89 runs sampled)
|
871
870
|
|
872
871
|
# .makeRe - braces
|
873
|
-
micromatch x
|
874
|
-
minimatch x
|
872
|
+
micromatch x 172,478 ops/sec ±2.37% (78 runs sampled)
|
873
|
+
minimatch x 96,087 ops/sec ±2.34% (88 runs sampled)))
|
875
874
|
|
876
875
|
# .makeRe braces - range (expanded)
|
877
|
-
micromatch x
|
878
|
-
minimatch x
|
876
|
+
micromatch x 26,973 ops/sec ±0.84% (89 runs sampled)
|
877
|
+
minimatch x 3,023 ops/sec ±0.99% (90 runs sampled))
|
879
878
|
|
880
879
|
# .makeRe braces - range (compiled)
|
881
|
-
micromatch x
|
882
|
-
minimatch x
|
880
|
+
micromatch x 152,892 ops/sec ±1.67% (83 runs sampled)
|
881
|
+
minimatch x 992 ops/sec ±3.50% (89 runs sampled)d))
|
883
882
|
|
884
883
|
# .makeRe braces - nested ranges (expanded)
|
885
|
-
micromatch x
|
886
|
-
minimatch x
|
884
|
+
micromatch x 15,816 ops/sec ±13.05% (80 runs sampled)
|
885
|
+
minimatch x 2,953 ops/sec ±1.64% (91 runs sampled)
|
887
886
|
|
888
887
|
# .makeRe braces - nested ranges (compiled)
|
889
|
-
micromatch x
|
890
|
-
minimatch x
|
888
|
+
micromatch x 110,881 ops/sec ±1.85% (82 runs sampled)
|
889
|
+
minimatch x 1,008 ops/sec ±1.51% (91 runs sampled)
|
891
890
|
|
892
891
|
# .makeRe braces - set (compiled)
|
893
|
-
micromatch x
|
894
|
-
minimatch x 43,
|
892
|
+
micromatch x 134,930 ops/sec ±3.54% (63 runs sampled))
|
893
|
+
minimatch x 43,242 ops/sec ±0.60% (93 runs sampled)
|
895
894
|
|
896
895
|
# .makeRe braces - nested sets (compiled)
|
897
|
-
micromatch x
|
898
|
-
minimatch x
|
896
|
+
micromatch x 94,455 ops/sec ±1.74% (69 runs sampled))
|
897
|
+
minimatch x 27,720 ops/sec ±1.84% (93 runs sampled))
|
899
898
|
```
|
900
899
|
|
901
900
|
## Contributing
|
@@ -964,23 +963,35 @@ You might also be interested in these projects:
|
|
964
963
|
|
965
964
|
| **Commits** | **Contributor** |
|
966
965
|
| --- | --- |
|
967
|
-
|
|
966
|
+
| 512 | [jonschlinkert](https://github.com/jonschlinkert) |
|
968
967
|
| 12 | [es128](https://github.com/es128) |
|
968
|
+
| 9 | [danez](https://github.com/danez) |
|
969
969
|
| 8 | [doowb](https://github.com/doowb) |
|
970
|
-
|
|
970
|
+
| 6 | [paulmillr](https://github.com/paulmillr) |
|
971
|
+
| 5 | [mrmlnc](https://github.com/mrmlnc) |
|
972
|
+
| 3 | [DrPizza](https://github.com/DrPizza) |
|
971
973
|
| 2 | [TrySound](https://github.com/TrySound) |
|
974
|
+
| 2 | [mceIdo](https://github.com/mceIdo) |
|
975
|
+
| 2 | [Glazy](https://github.com/Glazy) |
|
972
976
|
| 2 | [MartinKolarik](https://github.com/MartinKolarik) |
|
977
|
+
| 2 | [antonyk](https://github.com/antonyk) |
|
973
978
|
| 2 | [Tvrqvoise](https://github.com/Tvrqvoise) |
|
974
|
-
| 2 | [tunnckoCore](https://github.com/tunnckoCore) |
|
975
979
|
| 1 | [amilajack](https://github.com/amilajack) |
|
976
|
-
| 1 | [
|
980
|
+
| 1 | [Cslove](https://github.com/Cslove) |
|
977
981
|
| 1 | [devongovett](https://github.com/devongovett) |
|
978
982
|
| 1 | [DianeLooney](https://github.com/DianeLooney) |
|
979
983
|
| 1 | [UltCombo](https://github.com/UltCombo) |
|
984
|
+
| 1 | [frangio](https://github.com/frangio) |
|
985
|
+
| 1 | [joyceerhl](https://github.com/joyceerhl) |
|
986
|
+
| 1 | [juszczykjakub](https://github.com/juszczykjakub) |
|
987
|
+
| 1 | [muescha](https://github.com/muescha) |
|
988
|
+
| 1 | [sebdeckers](https://github.com/sebdeckers) |
|
980
989
|
| 1 | [tomByrer](https://github.com/tomByrer) |
|
981
990
|
| 1 | [fidian](https://github.com/fidian) |
|
991
|
+
| 1 | [curbengh](https://github.com/curbengh) |
|
982
992
|
| 1 | [simlu](https://github.com/simlu) |
|
983
993
|
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
994
|
+
| 1 | [yvele](https://github.com/yvele) |
|
984
995
|
|
985
996
|
### Author
|
986
997
|
|
@@ -992,9 +1003,9 @@ You might also be interested in these projects:
|
|
992
1003
|
|
993
1004
|
### License
|
994
1005
|
|
995
|
-
Copyright ©
|
1006
|
+
Copyright © 2022, [Jon Schlinkert](https://github.com/jonschlinkert).
|
996
1007
|
Released under the [MIT License](LICENSE).
|
997
1008
|
|
998
1009
|
***
|
999
1010
|
|
1000
|
-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on
|
1011
|
+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 24, 2022._
|
package/index.js
CHANGED
@@ -4,7 +4,7 @@ const util = require('util');
|
|
4
4
|
const braces = require('braces');
|
5
5
|
const picomatch = require('picomatch');
|
6
6
|
const utils = require('picomatch/lib/utils');
|
7
|
-
const isEmptyString = val =>
|
7
|
+
const isEmptyString = val => val === '' || val === './';
|
8
8
|
|
9
9
|
/**
|
10
10
|
* Returns an array of strings that match one or more glob patterns.
|
@@ -16,9 +16,9 @@ const isEmptyString = val => typeof val === 'string' && (val === '' || val === '
|
|
16
16
|
* console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
17
17
|
* //=> [ 'a.js' ]
|
18
18
|
* ```
|
19
|
-
* @param {String|Array<string>} list List of strings to match.
|
20
|
-
* @param {String|Array<string>} patterns One or more glob patterns to use for matching.
|
21
|
-
* @param {Object} options See available [options](#options)
|
19
|
+
* @param {String|Array<string>} `list` List of strings to match.
|
20
|
+
* @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
|
21
|
+
* @param {Object} `options` See available [options](#options)
|
22
22
|
* @return {Array} Returns an array of matches
|
23
23
|
* @summary false
|
24
24
|
* @api public
|
@@ -113,9 +113,9 @@ micromatch.matcher = (pattern, options) => picomatch(pattern, options);
|
|
113
113
|
* console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
114
114
|
* console.log(mm.isMatch('a.a', 'b.*')); //=> false
|
115
115
|
* ```
|
116
|
-
* @param {String} str The string to test.
|
117
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
118
|
-
* @param {Object} [options] See available [options](#options).
|
116
|
+
* @param {String} `str` The string to test.
|
117
|
+
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
118
|
+
* @param {Object} `[options]` See available [options](#options).
|
119
119
|
* @return {Boolean} Returns true if any patterns match `str`
|
120
120
|
* @api public
|
121
121
|
*/
|
@@ -155,10 +155,10 @@ micromatch.not = (list, patterns, options = {}) => {
|
|
155
155
|
items.push(state.output);
|
156
156
|
};
|
157
157
|
|
158
|
-
let matches = micromatch(list, patterns, { ...options, onResult });
|
158
|
+
let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
|
159
159
|
|
160
160
|
for (let item of items) {
|
161
|
-
if (!matches.
|
161
|
+
if (!matches.has(item)) {
|
162
162
|
result.add(item);
|
163
163
|
}
|
164
164
|
}
|
@@ -181,7 +181,7 @@ micromatch.not = (list, patterns, options = {}) => {
|
|
181
181
|
* @param {String} `str` The string to match.
|
182
182
|
* @param {String|Array} `patterns` Glob pattern to use for matching.
|
183
183
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
184
|
-
* @return {Boolean} Returns true if the
|
184
|
+
* @return {Boolean} Returns true if any of the patterns matches any part of `str`.
|
185
185
|
* @api public
|
186
186
|
*/
|
187
187
|
|
@@ -252,7 +252,7 @@ micromatch.matchKeys = (obj, patterns, options) => {
|
|
252
252
|
* @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
|
253
253
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
254
254
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
255
|
-
* @return {Boolean} Returns true if any patterns
|
255
|
+
* @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
|
256
256
|
* @api public
|
257
257
|
*/
|
258
258
|
|
@@ -288,7 +288,7 @@ micromatch.some = (list, patterns, options) => {
|
|
288
288
|
* @param {String|Array} `list` The string or array of strings to test.
|
289
289
|
* @param {String|Array} `patterns` One or more glob patterns to use for matching.
|
290
290
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
291
|
-
* @return {Boolean} Returns true if
|
291
|
+
* @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
|
292
292
|
* @api public
|
293
293
|
*/
|
294
294
|
|
@@ -354,7 +354,7 @@ micromatch.all = (str, patterns, options) => {
|
|
354
354
|
* @param {String} `glob` Glob pattern to use for matching.
|
355
355
|
* @param {String} `input` String to match
|
356
356
|
* @param {Object} `options` See available [options](#options) for changing how matches are performed
|
357
|
-
* @return {
|
357
|
+
* @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
|
358
358
|
* @api public
|
359
359
|
*/
|
360
360
|
|
@@ -408,7 +408,7 @@ micromatch.scan = (...args) => picomatch.scan(...args);
|
|
408
408
|
*
|
409
409
|
* ```js
|
410
410
|
* const mm = require('micromatch');
|
411
|
-
* const state = mm(pattern[, options]);
|
411
|
+
* const state = mm.parse(pattern[, options]);
|
412
412
|
* ```
|
413
413
|
* @param {String} `glob`
|
414
414
|
* @param {Object} `options`
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "micromatch",
|
3
3
|
"description": "Glob matching for javascript/node.js. A replacement and faster alternative to minimatch and multimatch.",
|
4
|
-
"version": "4.0.
|
4
|
+
"version": "4.0.5",
|
5
5
|
"homepage": "https://github.com/micromatch/micromatch",
|
6
6
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
7
7
|
"contributors": [
|
@@ -18,7 +18,8 @@
|
|
18
18
|
"Paul Miller (paulmillr.com)",
|
19
19
|
"Tom Byrer (https://github.com/tomByrer)",
|
20
20
|
"Tyler Akins (http://rumkin.com)",
|
21
|
-
"Peter Bright <drpizza@quiscalusmexicanus.org> (https://github.com/drpizza)"
|
21
|
+
"Peter Bright <drpizza@quiscalusmexicanus.org> (https://github.com/drpizza)",
|
22
|
+
"Kuba Juszczyk (https://github.com/ku8ar)"
|
22
23
|
],
|
23
24
|
"repository": "micromatch/micromatch",
|
24
25
|
"bugs": {
|
@@ -30,20 +31,20 @@
|
|
30
31
|
],
|
31
32
|
"main": "index.js",
|
32
33
|
"engines": {
|
33
|
-
"node": ">=8"
|
34
|
+
"node": ">=8.6"
|
34
35
|
},
|
35
36
|
"scripts": {
|
36
37
|
"test": "mocha"
|
37
38
|
},
|
38
39
|
"dependencies": {
|
39
|
-
"braces": "^3.0.
|
40
|
-
"picomatch": "^2.
|
40
|
+
"braces": "^3.0.2",
|
41
|
+
"picomatch": "^2.3.1"
|
41
42
|
},
|
42
43
|
"devDependencies": {
|
43
44
|
"fill-range": "^7.0.1",
|
44
45
|
"gulp-format-md": "^2.0.0",
|
45
|
-
"minimatch": "^
|
46
|
-
"mocha": "^
|
46
|
+
"minimatch": "^5.0.1",
|
47
|
+
"mocha": "^9.2.2",
|
47
48
|
"time-require": "github:jonschlinkert/time-require"
|
48
49
|
},
|
49
50
|
"keywords": [
|
package/CHANGELOG.md
DELETED
@@ -1,108 +0,0 @@
|
|
1
|
-
# Release history
|
2
|
-
|
3
|
-
All notable changes to this project will be documented in this file.
|
4
|
-
|
5
|
-
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
-
|
8
|
-
<details>
|
9
|
-
<summary><strong>Guiding Principles</strong></summary>
|
10
|
-
|
11
|
-
- Changelogs are for humans, not machines.
|
12
|
-
- There should be an entry for every single version.
|
13
|
-
- The same types of changes should be grouped.
|
14
|
-
- Versions and sections should be linkable.
|
15
|
-
- The latest version comes first.
|
16
|
-
- The release date of each versions is displayed.
|
17
|
-
- Mention whether you follow Semantic Versioning.
|
18
|
-
|
19
|
-
</details>
|
20
|
-
|
21
|
-
<details>
|
22
|
-
<summary><strong>Types of changes</strong></summary>
|
23
|
-
|
24
|
-
Changelog entries are classified using the following labels _(from [keep-a-changelog](http://keepachangelog.com/)_):
|
25
|
-
|
26
|
-
- `Added` for new features.
|
27
|
-
- `Changed` for changes in existing functionality.
|
28
|
-
- `Deprecated` for soon-to-be removed features.
|
29
|
-
- `Removed` for now removed features.
|
30
|
-
- `Fixed` for any bug fixes.
|
31
|
-
- `Security` in case of vulnerabilities.
|
32
|
-
|
33
|
-
</details>
|
34
|
-
|
35
|
-
## [4.0.0] - 2019-03-20
|
36
|
-
|
37
|
-
### Added
|
38
|
-
|
39
|
-
- Adds support for `options.onMatch`. See the readme for details
|
40
|
-
- Adds support for `options.onIgnore`. See the readme for details
|
41
|
-
- Adds support for `options.onResult`. See the readme for details
|
42
|
-
|
43
|
-
|
44
|
-
### Breaking changes
|
45
|
-
|
46
|
-
- Removed support for passing an array of brace patterns to `micromatch.braces()`.
|
47
|
-
- To strictly enforce closing brackets (for `{`, `[`, and `(`), you must now use `strictBrackets=true` instead of `strictErrors`.
|
48
|
-
- `cache` - caching and all related options and methods have been removed
|
49
|
-
- `options.unixify` was renamed to `options.windows`
|
50
|
-
- `options.nodupes` Was removed. Duplicates are always removed by default. You can override this with custom behavior by using the `onMatch`, `onResult` and `onIgnore` functions.
|
51
|
-
- `options.snapdragon` was removed, as snapdragon is no longer used.
|
52
|
-
- `options.sourcemap` was removed, as snapdragon is no longer used, which provided sourcemap support.
|
53
|
-
|
54
|
-
## [3.0.0] - 2017-04-11
|
55
|
-
|
56
|
-
Complete overhaul, with 36,000+ new unit tests validated against actual output generated by Bash and minimatch. More specifically, 35,000+ of the tests:
|
57
|
-
|
58
|
-
- micromatch results are directly compared to bash results
|
59
|
-
- in rare cases, when micromatch and bash disagree, micromatch's results are compared to minimatch's results
|
60
|
-
- micromatch is much more accurate than minimatch, so there were cases where I had to make assumptions. I'll try to document these.
|
61
|
-
|
62
|
-
This refactor introduces a parser and compiler that are supersets of more granular parsers and compilers from other sub-modules. Each of these sub-modules has a singular responsibility and focuses on a certain type of matching that aligns with a specific part of the Bash "expansion" API.
|
63
|
-
|
64
|
-
These sub-modules work like plugins to seamlessly create the micromatch parser/compiler, so that strings are parsed in one pass, an [AST is created](https://gist.github.com/jonschlinkert/099c8914f56529f75bc757cc9e5e8e2a), then a new string is generated by the compiler.
|
65
|
-
|
66
|
-
Here are those sub-modules with links to related prs on those modules if you want to see how they contribute to this code:
|
67
|
-
|
68
|
-
[nanomatch](https://github.com/jonschlinkert/nanomatch) (new library) - glob expansion (`*`, `**`, `?` and `[...]`))
|
69
|
-
[braces](https://github.com/jonschlinkert/braces/pull/10) - brace expansion (`{1..10}`, `{a,b,c}`, etc)
|
70
|
-
[extglob](https://github.com/jonschlinkert/extglob/pull/5) - extended globs (`!(a|b)`, `@(!(foo|bar))`, etc)
|
71
|
-
[expand-brackets](https://github.com/jonschlinkert/expand-brackets/pull/5) - POSIX character classes `[[:alpha:][:digit:]]`
|
72
|
-
|
73
|
-
**Added**
|
74
|
-
|
75
|
-
- source map support (optionally created when using parse or compile - I have no idea what the use case is yet, but they come for free) (note that source maps are not generated for brace expansion at present, since the braces compiler uses a different strategy. I'll update if/when this changes).
|
76
|
-
- parser is exposed, so that implementors can customize or override specific micromatch parsers if necessary
|
77
|
-
- compiler is exposed, so that implementors can customize or override specific micromatch compilers if necessary
|
78
|
-
|
79
|
-
**Fixed**
|
80
|
-
|
81
|
-
- more accurate matching (passes 100% of Bash 4.3 of the brace expansion and extglob unit tests, as well as all Bash glob tests that are relevant to node.js usage, all minimatch tests, all brace-expansion tests, and also passes a couple of tests that bash fails)
|
82
|
-
- even safer - micromatch has always generated optimized patterns so it's not subject to DoS exploits like minimatch (completely different than the regex DoS issue, minimatch and multimatch are still openly exposed to being used for DoS attacks), but more safeguards were built into this refactor
|
83
|
-
|
84
|
-
**Changed**
|
85
|
-
|
86
|
-
- the public API of this library did not change in this version and should be safe to upgrade without changing implentor code. However, we have released this as a major version for the following reasons:
|
87
|
-
- out of an abundance of caution due to the large amount of code changed in this release
|
88
|
-
- we have improved parser accuracy to such a degree that some implementors using invalid globs have noted change in behavior. If this is the case for you, please check that you are using a valid glob expression before logging a bug with this library
|
89
|
-
|
90
|
-
## [1.0.1] - 2016-12-12
|
91
|
-
|
92
|
-
**Added**
|
93
|
-
|
94
|
-
- Support for windows path edge cases where backslashes are used in brackets or other unusual combinations.
|
95
|
-
|
96
|
-
## [1.0.0] - 2016-12-12
|
97
|
-
|
98
|
-
Stable release.
|
99
|
-
|
100
|
-
## [0.1.0] - 2016-10-08
|
101
|
-
|
102
|
-
First release.
|
103
|
-
|
104
|
-
|
105
|
-
[Unreleased]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...HEAD
|
106
|
-
[0.2.0]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...0.2.0
|
107
|
-
|
108
|
-
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
|