micromatch 4.0.6 → 4.0.8
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.
- package/LICENSE +0 -0
- package/README.md +106 -99
- package/index.js +38 -42
- package/package.json +4 -4
package/LICENSE
CHANGED
File without changes
|
package/README.md
CHANGED
@@ -56,7 +56,7 @@ Please consider following this project's author, [Jon Schlinkert](https://github
|
|
56
56
|
|
57
57
|
## Install
|
58
58
|
|
59
|
-
Install with [npm](https://www.npmjs.com/)
|
59
|
+
Install with [npm](https://www.npmjs.com/):
|
60
60
|
|
61
61
|
```sh
|
62
62
|
$ npm install --save micromatch
|
@@ -99,15 +99,15 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
|
|
99
99
|
|
100
100
|
> micromatch is a [replacement](#switching-to-micromatch) for minimatch and multimatch
|
101
101
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
102
|
+
* Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch)
|
103
|
+
* 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.
|
104
|
+
* **Fast & Performant** - Loads in about 5ms and performs [fast matches](#benchmarks).
|
105
|
+
* **Glob matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories
|
106
|
+
* **[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.
|
107
|
+
* **Accurate** - Covers more scenarios [than minimatch](https://github.com/yarnpkg/yarn/pull/3339)
|
108
|
+
* **Well tested** - More than 5,000 [test assertions](./test)
|
109
|
+
* **Windows support** - More reliable windows support than minimatch and multimatch.
|
110
|
+
* **[Safe](https://github.com/micromatch/braces#braces-is-safe)** - Micromatch is not subject to DoS with brace patterns like minimatch and multimatch.
|
111
111
|
|
112
112
|
### Matching features
|
113
113
|
|
@@ -116,7 +116,7 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
|
|
116
116
|
* Negation (`'!a/*.js'`, `'*!(b).js'`)
|
117
117
|
* [extglobs](#extglobs) (`+(x|y)`, `!(a|b)`)
|
118
118
|
* [POSIX character classes](#posix-bracket-expressions) (`[[:alpha:][:digit:]]`)
|
119
|
-
* [brace expansion]
|
119
|
+
* [brace expansion](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
|
120
120
|
* regex character classes (`foo-[1-5].js`)
|
121
121
|
* regex logical "or" (`foo/(abc|xyz).js`)
|
122
122
|
|
@@ -167,7 +167,8 @@ console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
|
167
167
|
//=> [ 'a.js' ]
|
168
168
|
```
|
169
169
|
|
170
|
-
### [.matcher](index.js#
|
170
|
+
### [.matcher](index.js#L109)
|
171
|
+
|
171
172
|
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.
|
172
173
|
|
173
174
|
**Params**
|
@@ -187,7 +188,8 @@ console.log(isMatch('a.a')); //=> false
|
|
187
188
|
console.log(isMatch('a.b')); //=> true
|
188
189
|
```
|
189
190
|
|
190
|
-
### [.isMatch](index.js#
|
191
|
+
### [.isMatch](index.js#L128)
|
192
|
+
|
191
193
|
Returns true if **any** of the given glob `patterns` match the specified `string`.
|
192
194
|
|
193
195
|
**Params**
|
@@ -207,7 +209,8 @@ console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
207
209
|
console.log(mm.isMatch('a.a', 'b.*')); //=> false
|
208
210
|
```
|
209
211
|
|
210
|
-
### [.not](index.js#
|
212
|
+
### [.not](index.js#L153)
|
213
|
+
|
211
214
|
Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
212
215
|
|
213
216
|
**Params**
|
@@ -227,7 +230,8 @@ console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
|
227
230
|
//=> ['b.b', 'c.c']
|
228
231
|
```
|
229
232
|
|
230
|
-
### [.contains](index.js#
|
233
|
+
### [.contains](index.js#L193)
|
234
|
+
|
231
235
|
Returns true if the given `string` contains the given pattern. Similar to [.isMatch](#isMatch) but the pattern can match any part of the string.
|
232
236
|
|
233
237
|
**Params**
|
@@ -249,8 +253,9 @@ console.log(mm.contains('aa/bb/cc', '*d'));
|
|
249
253
|
//=> false
|
250
254
|
```
|
251
255
|
|
252
|
-
### [.matchKeys](index.js#
|
253
|
-
|
256
|
+
### [.matchKeys](index.js#L235)
|
257
|
+
|
258
|
+
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.
|
254
259
|
|
255
260
|
**Params**
|
256
261
|
|
@@ -270,7 +275,8 @@ console.log(mm.matchKeys(obj, '*b'));
|
|
270
275
|
//=> { ab: 'b' }
|
271
276
|
```
|
272
277
|
|
273
|
-
### [.some](index.js#
|
278
|
+
### [.some](index.js#L264)
|
279
|
+
|
274
280
|
Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
|
275
281
|
|
276
282
|
**Params**
|
@@ -292,7 +298,8 @@ console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
|
292
298
|
// false
|
293
299
|
```
|
294
300
|
|
295
|
-
### [.every](index.js#
|
301
|
+
### [.every](index.js#L300)
|
302
|
+
|
296
303
|
Returns true if every string in the given `list` matches any of the given glob `patterns`.
|
297
304
|
|
298
305
|
**Params**
|
@@ -318,7 +325,8 @@ console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
|
318
325
|
// false
|
319
326
|
```
|
320
327
|
|
321
|
-
### [.all](index.js#
|
328
|
+
### [.all](index.js#L339)
|
329
|
+
|
322
330
|
Returns true if **all** of the given `patterns` match the specified string.
|
323
331
|
|
324
332
|
**Params**
|
@@ -347,8 +355,9 @@ console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
|
347
355
|
// true
|
348
356
|
```
|
349
357
|
|
350
|
-
### [.capture](index.js#
|
351
|
-
|
358
|
+
### [.capture](index.js#L366)
|
359
|
+
|
360
|
+
Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
|
352
361
|
|
353
362
|
**Params**
|
354
363
|
|
@@ -369,7 +378,8 @@ console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
|
369
378
|
//=> null
|
370
379
|
```
|
371
380
|
|
372
|
-
### [.makeRe](index.js#
|
381
|
+
### [.makeRe](index.js#L392)
|
382
|
+
|
373
383
|
Create a regular expression from the given glob `pattern`.
|
374
384
|
|
375
385
|
**Params**
|
@@ -388,7 +398,8 @@ console.log(mm.makeRe('*.js'));
|
|
388
398
|
//=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
|
389
399
|
```
|
390
400
|
|
391
|
-
### [.scan](index.js#
|
401
|
+
### [.scan](index.js#L408)
|
402
|
+
|
392
403
|
Scan a glob pattern to separate the pattern into segments. Used by the [split](#split) method.
|
393
404
|
|
394
405
|
**Params**
|
@@ -404,7 +415,8 @@ const mm = require('micromatch');
|
|
404
415
|
const state = mm.scan(pattern[, options]);
|
405
416
|
```
|
406
417
|
|
407
|
-
### [.parse](index.js#
|
418
|
+
### [.parse](index.js#L424)
|
419
|
+
|
408
420
|
Parse a glob pattern to create the source string for a regular expression.
|
409
421
|
|
410
422
|
**Params**
|
@@ -420,13 +432,14 @@ const mm = require('micromatch');
|
|
420
432
|
const state = mm.parse(pattern[, options]);
|
421
433
|
```
|
422
434
|
|
423
|
-
### [.braces](index.js#
|
435
|
+
### [.braces](index.js#L451)
|
436
|
+
|
424
437
|
Process the given brace `pattern`.
|
425
438
|
|
426
439
|
**Params**
|
427
440
|
|
428
441
|
* `pattern` **{String}**: String with brace pattern to process.
|
429
|
-
* `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces]
|
442
|
+
* `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces](https://github.com/micromatch/braces) library for all available options.
|
430
443
|
* `returns` **{Array}**
|
431
444
|
|
432
445
|
**Example**
|
@@ -487,7 +500,7 @@ console.log(braces('foo/{a,b,c}/bar', { expand: true }));
|
|
487
500
|
|
488
501
|
### options.basename
|
489
502
|
|
490
|
-
Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch]
|
503
|
+
Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `matchBase`.
|
491
504
|
|
492
505
|
**Type**: `Boolean`
|
493
506
|
|
@@ -527,7 +540,7 @@ console.log(micromatch(files, '[a-c]*', { bash: false }));
|
|
527
540
|
|
528
541
|
**Default**: `undefined`
|
529
542
|
|
530
|
-
Custom function for expanding ranges in brace patterns. The [fill-range]
|
543
|
+
Custom function for expanding ranges in brace patterns. The [fill-range](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need.
|
531
544
|
|
532
545
|
**Example**
|
533
546
|
|
@@ -636,7 +649,7 @@ Alias for [options.nullglob](#options-nullglob).
|
|
636
649
|
|
637
650
|
### options.nullglob
|
638
651
|
|
639
|
-
If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch]
|
652
|
+
If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch](https://github.com/isaacs/minimatch) option `nonull`.
|
640
653
|
|
641
654
|
**Type**: `Boolean`
|
642
655
|
|
@@ -761,7 +774,7 @@ baz/2/qux
|
|
761
774
|
baz/3/qux
|
762
775
|
```
|
763
776
|
|
764
|
-
Visit [braces]
|
777
|
+
Visit [braces](https://github.com/micromatch/braces) to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues.
|
765
778
|
|
766
779
|
### Regex character classes
|
767
780
|
|
@@ -771,7 +784,7 @@ Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`:
|
|
771
784
|
* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
|
772
785
|
* `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']`
|
773
786
|
|
774
|
-
Learn about [regex character classes]
|
787
|
+
Learn about [regex character classes](http://www.regular-expressions.info/charclass.html).
|
775
788
|
|
776
789
|
### Regex groups
|
777
790
|
|
@@ -808,13 +821,13 @@ However, it's suprising how many edge cases and rabbit holes there are with glob
|
|
808
821
|
|
809
822
|
There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns.
|
810
823
|
|
811
|
-
|
812
|
-
|
824
|
+
* Micromatch exclusively and explicitly reserves backslashes for escaping characters in a glob pattern, even on windows, which is consistent with bash behavior. _More importantly, unescaping globs can result in unsafe regular expressions_.
|
825
|
+
* Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns.
|
813
826
|
|
814
827
|
We made this decision for micromatch for a couple of reasons:
|
815
828
|
|
816
|
-
|
817
|
-
|
829
|
+
* Consistency with bash conventions.
|
830
|
+
* Glob patterns are not filepaths. They are a type of [regular language](https://en.wikipedia.org/wiki/Regular_language) that is converted to a JavaScript regular expression. Thus, when forward slashes are defined in a glob pattern, the resulting regular expression will match windows or POSIX path separators just fine.
|
818
831
|
|
819
832
|
**A note about joining paths to globs**
|
820
833
|
|
@@ -842,7 +855,7 @@ $ npm run bench
|
|
842
855
|
|
843
856
|
### Latest results
|
844
857
|
|
845
|
-
As of
|
858
|
+
As of August 23, 2024 (longer bars are better):
|
846
859
|
|
847
860
|
```sh
|
848
861
|
# .makeRe star
|
@@ -902,25 +915,19 @@ All contributions are welcome! Please read [the contributing guide](.github/cont
|
|
902
915
|
|
903
916
|
Please create an issue if you encounter a bug or matching behavior that doesn't seem correct. If you find a matching-related issue, please:
|
904
917
|
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
918
|
+
* [research existing issues first](../../issues) (open and closed)
|
919
|
+
* visit the [GNU Bash documentation](https://www.gnu.org/software/bash/manual/) to see how Bash deals with the pattern
|
920
|
+
* visit the [minimatch](https://github.com/isaacs/minimatch) documentation to cross-check expected behavior in node.js
|
921
|
+
* if all else fails, since there is no real specification for globs we will probably need to discuss expected behavior and decide how to resolve it. which means any detail you can provide to help with this discussion would be greatly appreciated.
|
909
922
|
|
910
923
|
**Platform issues**
|
911
924
|
|
912
925
|
It's important to us that micromatch work consistently on all platforms. If you encounter any platform-specific matching or path related issues, please let us know (pull requests are also greatly appreciated).
|
913
926
|
|
914
|
-
[regular-language]: https://en.wikipedia.org/wiki/Regular_language
|
915
|
-
[bash]: https://www.gnu.org/software/bash/manual/
|
916
|
-
[charclass]: http://www.regular-expressions.info/charclass.html
|
917
|
-
[extended]: http://mywiki.wooledge.org/BashGuide/Patterns#Extended_Globs
|
918
|
-
[brackets]: https://github.com/micromatch/expand-brackets
|
919
|
-
[braces]: https://github.com/micromatch/braces
|
920
|
-
|
921
927
|
## About
|
928
|
+
|
922
929
|
<details>
|
923
|
-
|
930
|
+
<summary><strong>Contributing</strong></summary>
|
924
931
|
|
925
932
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
926
933
|
|
@@ -929,7 +936,7 @@ Please read the [contributing guide](.github/contributing.md) for advice on open
|
|
929
936
|
</details>
|
930
937
|
|
931
938
|
<details>
|
932
|
-
|
939
|
+
<summary><strong>Running Tests</strong></summary>
|
933
940
|
|
934
941
|
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:
|
935
942
|
|
@@ -940,7 +947,7 @@ $ npm install && npm test
|
|
940
947
|
</details>
|
941
948
|
|
942
949
|
<details>
|
943
|
-
|
950
|
+
<summary><strong>Building docs</strong></summary>
|
944
951
|
|
945
952
|
_(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.)_
|
946
953
|
|
@@ -956,62 +963,62 @@ $ npm install -g verbose/verb#dev verb-generate-readme && verb
|
|
956
963
|
|
957
964
|
You might also be interested in these projects:
|
958
965
|
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
966
|
+
* [braces](https://www.npmjs.com/package/braces): Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support… [more](https://github.com/micromatch/braces) | [homepage](https://github.com/micromatch/braces "Bash-like brace expansion, implemented in JavaScript. Safer than other brace expansion libs, with complete support for the Bash 4.3 braces specification, without sacrificing speed.")
|
967
|
+
* [expand-brackets](https://www.npmjs.com/package/expand-brackets): Expand POSIX bracket expressions (character classes) in glob patterns. | [homepage](https://github.com/micromatch/expand-brackets "Expand POSIX bracket expressions (character classes) in glob patterns.")
|
968
|
+
* [extglob](https://www.npmjs.com/package/extglob): Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob… [more](https://github.com/micromatch/extglob) | [homepage](https://github.com/micromatch/extglob "Extended glob support for JavaScript. Adds (almost) the expressive power of regular expressions to glob patterns.")
|
969
|
+
* [fill-range](https://www.npmjs.com/package/fill-range): Fill in a range of numbers or letters, optionally passing an increment or `step` to… [more](https://github.com/jonschlinkert/fill-range) | [homepage](https://github.com/jonschlinkert/fill-range "Fill in a range of numbers or letters, optionally passing an increment or `step` to use, or create a regex-compatible range with `options.toRegex`")
|
970
|
+
* [nanomatch](https://www.npmjs.com/package/nanomatch): Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash… [more](https://github.com/micromatch/nanomatch) | [homepage](https://github.com/micromatch/nanomatch "Fast, minimal glob matcher for node.js. Similar to micromatch, minimatch and multimatch, but complete Bash 4.3 wildcard support only (no support for exglobs, posix brackets or braces)")
|
964
971
|
|
965
972
|
### Contributors
|
966
|
-
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
| 2 | [
|
977
|
-
| 2 | [
|
978
|
-
| 2 | [MartinKolarik](https://github.com/MartinKolarik) |
|
979
|
-
| 2 | [
|
980
|
-
| 2 | [
|
981
|
-
|
|
982
|
-
| 1 | [
|
983
|
-
| 1 | [
|
984
|
-
| 1 | [
|
985
|
-
| 1 | [
|
986
|
-
| 1 | [
|
987
|
-
| 1 | [
|
988
|
-
| 1 | [
|
989
|
-
| 1 | [
|
990
|
-
| 1 | [sebdeckers](https://github.com/sebdeckers) |
|
991
|
-
| 1 | [
|
992
|
-
| 1 | [
|
993
|
-
| 1 | [
|
994
|
-
| 1 | [
|
995
|
-
| 1 | [
|
996
|
-
| 1 | [
|
973
|
+
|
974
|
+
| **Commits** | **Contributor** |
|
975
|
+
| --- | --- |
|
976
|
+
| 523 | [jonschlinkert](https://github.com/jonschlinkert) |
|
977
|
+
| 12 | [es128](https://github.com/es128) |
|
978
|
+
| 9 | [danez](https://github.com/danez) |
|
979
|
+
| 8 | [doowb](https://github.com/doowb) |
|
980
|
+
| 6 | [paulmillr](https://github.com/paulmillr) |
|
981
|
+
| 5 | [mrmlnc](https://github.com/mrmlnc) |
|
982
|
+
| 3 | [DrPizza](https://github.com/DrPizza) |
|
983
|
+
| 2 | [Tvrqvoise](https://github.com/Tvrqvoise) |
|
984
|
+
| 2 | [antonyk](https://github.com/antonyk) |
|
985
|
+
| 2 | [MartinKolarik](https://github.com/MartinKolarik) |
|
986
|
+
| 2 | [Glazy](https://github.com/Glazy) |
|
987
|
+
| 2 | [mceIdo](https://github.com/mceIdo) |
|
988
|
+
| 2 | [TrySound](https://github.com/TrySound) |
|
989
|
+
| 1 | [yvele](https://github.com/yvele) |
|
990
|
+
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
991
|
+
| 1 | [simlu](https://github.com/simlu) |
|
992
|
+
| 1 | [curbengh](https://github.com/curbengh) |
|
993
|
+
| 1 | [fidian](https://github.com/fidian) |
|
994
|
+
| 1 | [tomByrer](https://github.com/tomByrer) |
|
995
|
+
| 1 | [ZoomerTedJackson](https://github.com/ZoomerTedJackson) |
|
996
|
+
| 1 | [styfle](https://github.com/styfle) |
|
997
|
+
| 1 | [sebdeckers](https://github.com/sebdeckers) |
|
998
|
+
| 1 | [muescha](https://github.com/muescha) |
|
999
|
+
| 1 | [juszczykjakub](https://github.com/juszczykjakub) |
|
1000
|
+
| 1 | [joyceerhl](https://github.com/joyceerhl) |
|
1001
|
+
| 1 | [donatj](https://github.com/donatj) |
|
1002
|
+
| 1 | [frangio](https://github.com/frangio) |
|
1003
|
+
| 1 | [UltCombo](https://github.com/UltCombo) |
|
1004
|
+
| 1 | [DianeLooney](https://github.com/DianeLooney) |
|
1005
|
+
| 1 | [devongovett](https://github.com/devongovett) |
|
1006
|
+
| 1 | [Cslove](https://github.com/Cslove) |
|
1007
|
+
| 1 | [amilajack](https://github.com/amilajack) |
|
997
1008
|
|
998
1009
|
### Author
|
1010
|
+
|
999
1011
|
**Jon Schlinkert**
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1012
|
+
|
1013
|
+
* [GitHub Profile](https://github.com/jonschlinkert)
|
1014
|
+
* [Twitter Profile](https://twitter.com/jonschlinkert)
|
1015
|
+
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
1003
1016
|
|
1004
1017
|
### License
|
1005
|
-
|
1018
|
+
|
1019
|
+
Copyright © 2024, [Jon Schlinkert](https://github.com/jonschlinkert).
|
1006
1020
|
Released under the [MIT License](LICENSE).
|
1007
1021
|
|
1008
1022
|
***
|
1009
1023
|
|
1010
|
-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on
|
1011
|
-
|
1012
|
-
[extglob]: https://github.com/micromatch/extglob
|
1013
|
-
[fill-range]: https://github.com/jonschlinkert/fill-range
|
1014
|
-
[glob-object]: https://github.com/jonschlinkert/glob-object
|
1015
|
-
[minimatch]: https://github.com/isaacs/minimatch
|
1016
|
-
[multimatch]: https://github.com/sindresorhus/multimatch
|
1017
|
-
|
1024
|
+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on August 23, 2024._
|
package/index.js
CHANGED
@@ -6,7 +6,6 @@ const picomatch = require('picomatch');
|
|
6
6
|
const utils = require('picomatch/lib/utils');
|
7
7
|
|
8
8
|
const isEmptyString = v => v === '' || v === './';
|
9
|
-
const isObject = v => v !== null && typeof v === 'object' && !Array.isArray(v);
|
10
9
|
const hasBraces = v => {
|
11
10
|
const index = v.indexOf('{');
|
12
11
|
return index > -1 && v.indexOf('}', index) > -1;
|
@@ -34,12 +33,12 @@ const micromatch = (list, patterns, options) => {
|
|
34
33
|
patterns = [].concat(patterns);
|
35
34
|
list = [].concat(list);
|
36
35
|
|
37
|
-
|
38
|
-
|
39
|
-
|
36
|
+
let omit = new Set();
|
37
|
+
let keep = new Set();
|
38
|
+
let items = new Set();
|
40
39
|
let negatives = 0;
|
41
40
|
|
42
|
-
|
41
|
+
let onResult = state => {
|
43
42
|
items.add(state.output);
|
44
43
|
if (options && options.onResult) {
|
45
44
|
options.onResult(state);
|
@@ -47,14 +46,14 @@ const micromatch = (list, patterns, options) => {
|
|
47
46
|
};
|
48
47
|
|
49
48
|
for (let i = 0; i < patterns.length; i++) {
|
50
|
-
|
51
|
-
|
49
|
+
let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
|
50
|
+
let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
52
51
|
if (negated) negatives++;
|
53
52
|
|
54
|
-
for (
|
55
|
-
|
53
|
+
for (let item of list) {
|
54
|
+
let matched = isMatch(item, true);
|
56
55
|
|
57
|
-
|
56
|
+
let match = negated ? !matched.isMatch : matched.isMatch;
|
58
57
|
if (!match) continue;
|
59
58
|
|
60
59
|
if (negated) {
|
@@ -66,8 +65,8 @@ const micromatch = (list, patterns, options) => {
|
|
66
65
|
}
|
67
66
|
}
|
68
67
|
|
69
|
-
|
70
|
-
|
68
|
+
let result = negatives === patterns.length ? [...items] : [...keep];
|
69
|
+
let matches = result.filter(item => !omit.has(item));
|
71
70
|
|
72
71
|
if (options && matches.length === 0) {
|
73
72
|
if (options.failglob === true) {
|
@@ -100,17 +99,14 @@ micromatch.match = micromatch;
|
|
100
99
|
* const isMatch = mm.matcher('*.!(*a)');
|
101
100
|
* console.log(isMatch('a.a')); //=> false
|
102
101
|
* console.log(isMatch('a.b')); //=> true
|
103
|
-
*
|
104
|
-
* const isMatch = mm.matcher(['b.*', '*.a']);
|
105
|
-
* console.log(isMatch('a.a')); //=> true
|
106
102
|
* ```
|
107
|
-
* @param {String
|
103
|
+
* @param {String} `pattern` Glob pattern
|
108
104
|
* @param {Object} `options`
|
109
105
|
* @return {Function} Returns a matcher function.
|
110
106
|
* @api public
|
111
107
|
*/
|
112
108
|
|
113
|
-
micromatch.matcher = (pattern, options) => picomatch(pattern,
|
109
|
+
micromatch.matcher = (pattern, options) => picomatch(pattern, options);
|
114
110
|
|
115
111
|
/**
|
116
112
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
@@ -156,17 +152,17 @@ micromatch.any = micromatch.isMatch;
|
|
156
152
|
|
157
153
|
micromatch.not = (list, patterns, options = {}) => {
|
158
154
|
patterns = [].concat(patterns).map(String);
|
159
|
-
|
160
|
-
|
155
|
+
let result = new Set();
|
156
|
+
let items = [];
|
161
157
|
|
162
|
-
|
158
|
+
let onResult = state => {
|
163
159
|
if (options.onResult) options.onResult(state);
|
164
160
|
items.push(state.output);
|
165
161
|
};
|
166
162
|
|
167
|
-
|
163
|
+
let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
|
168
164
|
|
169
|
-
for (
|
165
|
+
for (let item of items) {
|
170
166
|
if (!matches.has(item)) {
|
171
167
|
result.add(item);
|
172
168
|
}
|
@@ -237,12 +233,12 @@ micromatch.contains = (str, pattern, options) => {
|
|
237
233
|
*/
|
238
234
|
|
239
235
|
micromatch.matchKeys = (obj, patterns, options) => {
|
240
|
-
if (!isObject(obj)) {
|
236
|
+
if (!utils.isObject(obj)) {
|
241
237
|
throw new TypeError('Expected the first argument to be an object');
|
242
238
|
}
|
243
|
-
|
244
|
-
|
245
|
-
for (
|
239
|
+
let keys = micromatch(Object.keys(obj), patterns, options);
|
240
|
+
let res = {};
|
241
|
+
for (let key of keys) res[key] = obj[key];
|
246
242
|
return res;
|
247
243
|
};
|
248
244
|
|
@@ -266,10 +262,10 @@ micromatch.matchKeys = (obj, patterns, options) => {
|
|
266
262
|
*/
|
267
263
|
|
268
264
|
micromatch.some = (list, patterns, options) => {
|
269
|
-
|
265
|
+
let items = [].concat(list);
|
270
266
|
|
271
|
-
for (
|
272
|
-
|
267
|
+
for (let pattern of [].concat(patterns)) {
|
268
|
+
let isMatch = picomatch(String(pattern), options);
|
273
269
|
if (items.some(item => isMatch(item))) {
|
274
270
|
return true;
|
275
271
|
}
|
@@ -302,10 +298,10 @@ micromatch.some = (list, patterns, options) => {
|
|
302
298
|
*/
|
303
299
|
|
304
300
|
micromatch.every = (list, patterns, options) => {
|
305
|
-
|
301
|
+
let items = [].concat(list);
|
306
302
|
|
307
|
-
for (
|
308
|
-
|
303
|
+
for (let pattern of [].concat(patterns)) {
|
304
|
+
let isMatch = picomatch(String(pattern), options);
|
309
305
|
if (!items.every(item => isMatch(item))) {
|
310
306
|
return false;
|
311
307
|
}
|
@@ -345,7 +341,7 @@ micromatch.all = (str, patterns, options) => {
|
|
345
341
|
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
346
342
|
}
|
347
343
|
|
348
|
-
return [].concat(patterns).every(p => picomatch(p,
|
344
|
+
return [].concat(patterns).every(p => picomatch(p, options)(str));
|
349
345
|
};
|
350
346
|
|
351
347
|
/**
|
@@ -368,9 +364,9 @@ micromatch.all = (str, patterns, options) => {
|
|
368
364
|
*/
|
369
365
|
|
370
366
|
micromatch.capture = (glob, input, options) => {
|
371
|
-
|
372
|
-
|
373
|
-
|
367
|
+
let posix = utils.isWindows(options);
|
368
|
+
let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
|
369
|
+
let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
|
374
370
|
|
375
371
|
if (match) {
|
376
372
|
return match.slice(1).map(v => v === void 0 ? '' : v);
|
@@ -393,7 +389,7 @@ micromatch.capture = (glob, input, options) => {
|
|
393
389
|
* @api public
|
394
390
|
*/
|
395
391
|
|
396
|
-
micromatch.makeRe = (
|
392
|
+
micromatch.makeRe = (...args) => picomatch.makeRe(...args);
|
397
393
|
|
398
394
|
/**
|
399
395
|
* Scan a glob pattern to separate the pattern into segments. Used
|
@@ -409,7 +405,7 @@ micromatch.makeRe = (pattern, options) => picomatch.makeRe(pattern, { windows: t
|
|
409
405
|
* @api public
|
410
406
|
*/
|
411
407
|
|
412
|
-
micromatch.scan = (
|
408
|
+
micromatch.scan = (...args) => picomatch.scan(...args);
|
413
409
|
|
414
410
|
/**
|
415
411
|
* Parse a glob pattern to create the source string for a regular
|
@@ -426,10 +422,10 @@ micromatch.scan = (pattern, options) => picomatch.scan(pattern, { windows: true,
|
|
426
422
|
*/
|
427
423
|
|
428
424
|
micromatch.parse = (patterns, options) => {
|
429
|
-
|
430
|
-
for (
|
431
|
-
for (
|
432
|
-
res.push(picomatch.parse(str,
|
425
|
+
let res = [];
|
426
|
+
for (let pattern of [].concat(patterns || [])) {
|
427
|
+
for (let str of braces(String(pattern), options)) {
|
428
|
+
res.push(picomatch.parse(str, options));
|
433
429
|
}
|
434
430
|
}
|
435
431
|
return res;
|
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.8",
|
5
5
|
"homepage": "https://github.com/micromatch/micromatch",
|
6
6
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
7
7
|
"contributors": [
|
@@ -38,13 +38,13 @@
|
|
38
38
|
},
|
39
39
|
"dependencies": {
|
40
40
|
"braces": "^3.0.3",
|
41
|
-
"picomatch": "^
|
41
|
+
"picomatch": "^2.3.1"
|
42
42
|
},
|
43
43
|
"devDependencies": {
|
44
44
|
"fill-range": "^7.0.1",
|
45
45
|
"gulp-format-md": "^2.0.0",
|
46
|
-
"minimatch": "^
|
47
|
-
"mocha": "^
|
46
|
+
"minimatch": "^5.0.1",
|
47
|
+
"mocha": "^9.2.2",
|
48
48
|
"time-require": "github:jonschlinkert/time-require"
|
49
49
|
},
|
50
50
|
"keywords": [
|