micromatch 4.0.4 → 4.0.6
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/LICENSE +0 -0
- package/README.md +139 -130
- package/index.js +53 -42
- package/package.json +5 -5
- package/CHANGELOG.md +0 -109
package/LICENSE
CHANGED
File without changes
|
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)
|
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
|
|
@@ -9,57 +9,67 @@ Please consider following this project's author, [Jon Schlinkert](https://github
|
|
9
9
|
<details>
|
10
10
|
<summary><strong>Details</strong></summary>
|
11
11
|
|
12
|
-
|
13
|
-
- [
|
14
|
-
|
15
|
-
* [
|
16
|
-
|
17
|
-
|
18
|
-
* [
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
* [
|
23
|
-
* [
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
* [
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
* [
|
47
|
-
|
48
|
-
|
49
|
-
* [
|
50
|
-
|
51
|
-
|
12
|
+
* [Install](#install)
|
13
|
+
- [Sponsors](#sponsors)
|
14
|
+
* [Gold Sponsors](#gold-sponsors)
|
15
|
+
* [Quickstart](#quickstart)
|
16
|
+
* [Why use micromatch?](#why-use-micromatch)
|
17
|
+
+ [Matching features](#matching-features)
|
18
|
+
* [Switching to micromatch](#switching-to-micromatch)
|
19
|
+
+ [From minimatch](#from-minimatch)
|
20
|
+
+ [From multimatch](#from-multimatch)
|
21
|
+
* [API](#api)
|
22
|
+
* [Options](#options)
|
23
|
+
* [Options Examples](#options-examples)
|
24
|
+
+ [options.basename](#optionsbasename)
|
25
|
+
+ [options.bash](#optionsbash)
|
26
|
+
+ [options.expandRange](#optionsexpandrange)
|
27
|
+
+ [options.format](#optionsformat)
|
28
|
+
+ [options.ignore](#optionsignore)
|
29
|
+
+ [options.matchBase](#optionsmatchbase)
|
30
|
+
+ [options.noextglob](#optionsnoextglob)
|
31
|
+
+ [options.nonegate](#optionsnonegate)
|
32
|
+
+ [options.noglobstar](#optionsnoglobstar)
|
33
|
+
+ [options.nonull](#optionsnonull)
|
34
|
+
+ [options.nullglob](#optionsnullglob)
|
35
|
+
+ [options.onIgnore](#optionsonignore)
|
36
|
+
+ [options.onMatch](#optionsonmatch)
|
37
|
+
+ [options.onResult](#optionsonresult)
|
38
|
+
+ [options.posixSlashes](#optionsposixslashes)
|
39
|
+
+ [options.unescape](#optionsunescape)
|
40
|
+
* [Extended globbing](#extended-globbing)
|
41
|
+
+ [Extglobs](#extglobs)
|
42
|
+
+ [Braces](#braces)
|
43
|
+
+ [Regex character classes](#regex-character-classes)
|
44
|
+
+ [Regex groups](#regex-groups)
|
45
|
+
+ [POSIX bracket expressions](#posix-bracket-expressions)
|
46
|
+
* [Notes](#notes)
|
47
|
+
+ [Bash 4.3 parity](#bash-43-parity)
|
48
|
+
+ [Backslashes](#backslashes)
|
49
|
+
* [Benchmarks](#benchmarks)
|
50
|
+
+ [Running benchmarks](#running-benchmarks)
|
51
|
+
+ [Latest results](#latest-results)
|
52
|
+
* [Contributing](#contributing)
|
53
|
+
* [About](#about)
|
52
54
|
|
53
55
|
</details>
|
54
56
|
|
55
57
|
## Install
|
56
58
|
|
57
|
-
Install with [npm](https://www.npmjs.com/):
|
59
|
+
Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.org/en/) >=8.6):
|
58
60
|
|
59
61
|
```sh
|
60
62
|
$ npm install --save micromatch
|
61
63
|
```
|
62
64
|
|
65
|
+
<br />
|
66
|
+
|
67
|
+
# Sponsors
|
68
|
+
|
69
|
+
[Become a Sponsor](https://github.com/sponsors/jonschlinkert) to add your logo to this README, or any of [my other projects](https://github.com/jonschlinkert?tab=repositories&q=&type=&language=&sort=stargazers)
|
70
|
+
|
71
|
+
<br />
|
72
|
+
|
63
73
|
## Quickstart
|
64
74
|
|
65
75
|
```js
|
@@ -89,24 +99,24 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
|
|
89
99
|
|
90
100
|
> micromatch is a [replacement](#switching-to-micromatch) for minimatch and multimatch
|
91
101
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
102
|
+
- Supports all of the same matching features as [minimatch][] and [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][braces]{#braces-is-safe}** - Micromatch is not subject to DoS with brace patterns like minimatch and multimatch.
|
101
111
|
|
102
112
|
### Matching features
|
103
113
|
|
104
114
|
* Support for multiple glob patterns (no need for wrappers like multimatch)
|
105
115
|
* Wildcards (`**`, `*.js`)
|
106
|
-
* Negation (`'!a/*.js'`, `'*!(b).js'
|
116
|
+
* Negation (`'!a/*.js'`, `'*!(b).js'`)
|
107
117
|
* [extglobs](#extglobs) (`+(x|y)`, `!(a|b)`)
|
108
118
|
* [POSIX character classes](#posix-bracket-expressions) (`[[:alpha:][:digit:]]`)
|
109
|
-
* [brace expansion]
|
119
|
+
* [brace expansion][braces] (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
|
110
120
|
* regex character classes (`foo-[1-5].js`)
|
111
121
|
* regex logical "or" (`foo/(abc|xyz).js`)
|
112
122
|
|
@@ -158,7 +168,6 @@ console.log(mm(['a.js', 'a.txt'], ['*.js']));
|
|
158
168
|
```
|
159
169
|
|
160
170
|
### [.matcher](index.js#L104)
|
161
|
-
|
162
171
|
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
172
|
|
164
173
|
**Params**
|
@@ -179,7 +188,6 @@ console.log(isMatch('a.b')); //=> true
|
|
179
188
|
```
|
180
189
|
|
181
190
|
### [.isMatch](index.js#L123)
|
182
|
-
|
183
191
|
Returns true if **any** of the given glob `patterns` match the specified `string`.
|
184
192
|
|
185
193
|
**Params**
|
@@ -200,7 +208,6 @@ console.log(mm.isMatch('a.a', 'b.*')); //=> false
|
|
200
208
|
```
|
201
209
|
|
202
210
|
### [.not](index.js#L148)
|
203
|
-
|
204
211
|
Returns a list of strings that _**do not match any**_ of the given `patterns`.
|
205
212
|
|
206
213
|
**Params**
|
@@ -221,7 +228,6 @@ console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
|
|
221
228
|
```
|
222
229
|
|
223
230
|
### [.contains](index.js#L188)
|
224
|
-
|
225
231
|
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
232
|
|
227
233
|
**Params**
|
@@ -244,8 +250,7 @@ console.log(mm.contains('aa/bb/cc', '*d'));
|
|
244
250
|
```
|
245
251
|
|
246
252
|
### [.matchKeys](index.js#L230)
|
247
|
-
|
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.
|
253
|
+
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][] instead.
|
249
254
|
|
250
255
|
**Params**
|
251
256
|
|
@@ -266,7 +271,6 @@ console.log(mm.matchKeys(obj, '*b'));
|
|
266
271
|
```
|
267
272
|
|
268
273
|
### [.some](index.js#L259)
|
269
|
-
|
270
274
|
Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
|
271
275
|
|
272
276
|
**Params**
|
@@ -289,7 +293,6 @@ console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
|
|
289
293
|
```
|
290
294
|
|
291
295
|
### [.every](index.js#L295)
|
292
|
-
|
293
296
|
Returns true if every string in the given `list` matches any of the given glob `patterns`.
|
294
297
|
|
295
298
|
**Params**
|
@@ -316,7 +319,6 @@ console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
|
|
316
319
|
```
|
317
320
|
|
318
321
|
### [.all](index.js#L334)
|
319
|
-
|
320
322
|
Returns true if **all** of the given `patterns` match the specified string.
|
321
323
|
|
322
324
|
**Params**
|
@@ -346,8 +348,7 @@ console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
|
|
346
348
|
```
|
347
349
|
|
348
350
|
### [.capture](index.js#L361)
|
349
|
-
|
350
|
-
Returns an array of matches captured by `pattern` in `string, or`null` if the pattern did not match.
|
351
|
+
Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
|
351
352
|
|
352
353
|
**Params**
|
353
354
|
|
@@ -369,7 +370,6 @@ console.log(mm.capture('test/*.js', 'foo/bar.css'));
|
|
369
370
|
```
|
370
371
|
|
371
372
|
### [.makeRe](index.js#L387)
|
372
|
-
|
373
373
|
Create a regular expression from the given glob `pattern`.
|
374
374
|
|
375
375
|
**Params**
|
@@ -389,7 +389,6 @@ console.log(mm.makeRe('*.js'));
|
|
389
389
|
```
|
390
390
|
|
391
391
|
### [.scan](index.js#L403)
|
392
|
-
|
393
392
|
Scan a glob pattern to separate the pattern into segments. Used by the [split](#split) method.
|
394
393
|
|
395
394
|
**Params**
|
@@ -406,7 +405,6 @@ const state = mm.scan(pattern[, options]);
|
|
406
405
|
```
|
407
406
|
|
408
407
|
### [.parse](index.js#L419)
|
409
|
-
|
410
408
|
Parse a glob pattern to create the source string for a regular expression.
|
411
409
|
|
412
410
|
**Params**
|
@@ -419,17 +417,16 @@ Parse a glob pattern to create the source string for a regular expression.
|
|
419
417
|
|
420
418
|
```js
|
421
419
|
const mm = require('micromatch');
|
422
|
-
const state = mm(pattern[, options]);
|
420
|
+
const state = mm.parse(pattern[, options]);
|
423
421
|
```
|
424
422
|
|
425
423
|
### [.braces](index.js#L446)
|
426
|
-
|
427
424
|
Process the given brace `pattern`.
|
428
425
|
|
429
426
|
**Params**
|
430
427
|
|
431
428
|
* `pattern` **{String}**: String with brace pattern to process.
|
432
|
-
* `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces]
|
429
|
+
* `options` **{Object}**: Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
|
433
430
|
* `returns` **{Array}**
|
434
431
|
|
435
432
|
**Example**
|
@@ -490,7 +487,7 @@ console.log(braces('foo/{a,b,c}/bar', { expand: true }));
|
|
490
487
|
|
491
488
|
### options.basename
|
492
489
|
|
493
|
-
Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch]
|
490
|
+
Allow glob patterns without slashes to match a file path based on its basename. Same behavior as [minimatch][] option `matchBase`.
|
494
491
|
|
495
492
|
**Type**: `Boolean`
|
496
493
|
|
@@ -530,7 +527,7 @@ console.log(micromatch(files, '[a-c]*', { bash: false }));
|
|
530
527
|
|
531
528
|
**Default**: `undefined`
|
532
529
|
|
533
|
-
Custom function for expanding ranges in brace patterns. The [fill-range]
|
530
|
+
Custom function for expanding ranges in brace patterns. The [fill-range][] library is ideal for this purpose, or you can use custom code to do whatever you need.
|
534
531
|
|
535
532
|
**Example**
|
536
533
|
|
@@ -639,7 +636,7 @@ Alias for [options.nullglob](#options-nullglob).
|
|
639
636
|
|
640
637
|
### options.nullglob
|
641
638
|
|
642
|
-
If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch]
|
639
|
+
If `true`, when no matches are found the actual (arrayified) glob pattern is returned instead of an empty array. Same behavior as [minimatch][] option `nonull`.
|
643
640
|
|
644
641
|
**Type**: `Boolean`
|
645
642
|
|
@@ -764,7 +761,7 @@ baz/2/qux
|
|
764
761
|
baz/3/qux
|
765
762
|
```
|
766
763
|
|
767
|
-
Visit [braces]
|
764
|
+
Visit [braces][] to see the full range of features and options related to brace expansion, or to create brace matching or expansion related issues.
|
768
765
|
|
769
766
|
### Regex character classes
|
770
767
|
|
@@ -774,7 +771,7 @@ Given the list: `['a.js', 'b.js', 'c.js', 'd.js', 'E.js']`:
|
|
774
771
|
* `[b-d].js`: matches from `b` to `d`, returning `['b.js', 'c.js', 'd.js']`
|
775
772
|
* `a/[A-Z].js`: matches and uppercase letter, returning `['a/E.md']`
|
776
773
|
|
777
|
-
Learn about [regex character classes]
|
774
|
+
Learn about [regex character classes][charclass].
|
778
775
|
|
779
776
|
### Regex groups
|
780
777
|
|
@@ -811,13 +808,13 @@ However, it's suprising how many edge cases and rabbit holes there are with glob
|
|
811
808
|
|
812
809
|
There is an important, notable difference between minimatch and micromatch _in regards to how backslashes are handled_ in glob patterns.
|
813
810
|
|
814
|
-
|
815
|
-
|
811
|
+
- 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_.
|
812
|
+
- Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns.
|
816
813
|
|
817
814
|
We made this decision for micromatch for a couple of reasons:
|
818
815
|
|
819
|
-
|
820
|
-
|
816
|
+
- Consistency with bash conventions.
|
817
|
+
- Glob patterns are not filepaths. They are a type of [regular language][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.
|
821
818
|
|
822
819
|
**A note about joining paths to globs**
|
823
820
|
|
@@ -845,7 +842,7 @@ $ npm run bench
|
|
845
842
|
|
846
843
|
### Latest results
|
847
844
|
|
848
|
-
As of
|
845
|
+
As of July 12, 2023 (longer bars are better):
|
849
846
|
|
850
847
|
```sh
|
851
848
|
# .makeRe star
|
@@ -905,19 +902,25 @@ All contributions are welcome! Please read [the contributing guide](.github/cont
|
|
905
902
|
|
906
903
|
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:
|
907
904
|
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
905
|
+
- [research existing issues first](../../issues) (open and closed)
|
906
|
+
- visit the [GNU Bash documentation][bash] to see how Bash deals with the pattern
|
907
|
+
- visit the [minimatch][] documentation to cross-check expected behavior in node.js
|
908
|
+
- 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.
|
912
909
|
|
913
910
|
**Platform issues**
|
914
911
|
|
915
912
|
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).
|
916
913
|
|
917
|
-
|
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
|
918
920
|
|
921
|
+
## About
|
919
922
|
<details>
|
920
|
-
<summary><strong>Contributing</strong></summary>
|
923
|
+
<summary><strong>Contributing</strong></summary>
|
921
924
|
|
922
925
|
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
|
923
926
|
|
@@ -926,7 +929,7 @@ Please read the [contributing guide](.github/contributing.md) for advice on open
|
|
926
929
|
</details>
|
927
930
|
|
928
931
|
<details>
|
929
|
-
<summary><strong>Running Tests</strong></summary>
|
932
|
+
<summary><strong>Running Tests</strong></summary>
|
930
933
|
|
931
934
|
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:
|
932
935
|
|
@@ -937,7 +940,7 @@ $ npm install && npm test
|
|
937
940
|
</details>
|
938
941
|
|
939
942
|
<details>
|
940
|
-
<summary><strong>Building docs</strong></summary>
|
943
|
+
<summary><strong>Building docs</strong></summary>
|
941
944
|
|
942
945
|
_(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.)_
|
943
946
|
|
@@ -953,56 +956,62 @@ $ npm install -g verbose/verb#dev verb-generate-readme && verb
|
|
953
956
|
|
954
957
|
You might also be interested in these projects:
|
955
958
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
959
|
+
- [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.")
|
960
|
+
- [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.")
|
961
|
+
- [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.")
|
962
|
+
- [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`")
|
963
|
+
- [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)")
|
961
964
|
|
962
965
|
### Contributors
|
963
|
-
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
| 8 | [doowb](https://github.com/doowb) |
|
969
|
-
| 6 | [paulmillr](https://github.com/paulmillr) |
|
970
|
-
| 5 | [mrmlnc](https://github.com/mrmlnc) |
|
971
|
-
|
|
972
|
-
|
|
973
|
-
| 2 | [
|
974
|
-
| 2 | [
|
975
|
-
| 2 | [
|
976
|
-
| 2 | [
|
977
|
-
| 2 | [Tvrqvoise](https://github.com/Tvrqvoise) |
|
978
|
-
| 1 | [amilajack](https://github.com/amilajack) |
|
979
|
-
| 1 | [Cslove](https://github.com/Cslove) |
|
980
|
-
| 1 | [devongovett](https://github.com/devongovett) |
|
981
|
-
| 1 | [DianeLooney](https://github.com/DianeLooney) |
|
982
|
-
| 1 | [UltCombo](https://github.com/UltCombo) |
|
983
|
-
| 1 | [frangio](https://github.com/frangio) |
|
984
|
-
| 1 | [
|
985
|
-
| 1 | [
|
986
|
-
| 1 | [
|
987
|
-
| 1 | [
|
988
|
-
| 1 | [
|
989
|
-
| 1 | [
|
990
|
-
| 1 | [
|
991
|
-
| 1 | [
|
966
|
+
| **Commits** | **Contributor** |
|
967
|
+
| --- | --- |
|
968
|
+
| 515 | [jonschlinkert](https://github.com/jonschlinkert) |
|
969
|
+
| 12 | [es128](https://github.com/es128) |
|
970
|
+
| 9 | [danez](https://github.com/danez) |
|
971
|
+
| 8 | [doowb](https://github.com/doowb) |
|
972
|
+
| 6 | [paulmillr](https://github.com/paulmillr) |
|
973
|
+
| 5 | [mrmlnc](https://github.com/mrmlnc) |
|
974
|
+
| 3 | [DrPizza](https://github.com/DrPizza) |
|
975
|
+
| 2 | [TrySound](https://github.com/TrySound) |
|
976
|
+
| 2 | [mceIdo](https://github.com/mceIdo) |
|
977
|
+
| 2 | [Glazy](https://github.com/Glazy) |
|
978
|
+
| 2 | [MartinKolarik](https://github.com/MartinKolarik) |
|
979
|
+
| 2 | [antonyk](https://github.com/antonyk) |
|
980
|
+
| 2 | [Tvrqvoise](https://github.com/Tvrqvoise) |
|
981
|
+
| 1 | [amilajack](https://github.com/amilajack) |
|
982
|
+
| 1 | [Cslove](https://github.com/Cslove) |
|
983
|
+
| 1 | [devongovett](https://github.com/devongovett) |
|
984
|
+
| 1 | [DianeLooney](https://github.com/DianeLooney) |
|
985
|
+
| 1 | [UltCombo](https://github.com/UltCombo) |
|
986
|
+
| 1 | [frangio](https://github.com/frangio) |
|
987
|
+
| 1 | [joyceerhl](https://github.com/joyceerhl) |
|
988
|
+
| 1 | [juszczykjakub](https://github.com/juszczykjakub) |
|
989
|
+
| 1 | [muescha](https://github.com/muescha) |
|
990
|
+
| 1 | [sebdeckers](https://github.com/sebdeckers) |
|
991
|
+
| 1 | [tomByrer](https://github.com/tomByrer) |
|
992
|
+
| 1 | [fidian](https://github.com/fidian) |
|
993
|
+
| 1 | [curbengh](https://github.com/curbengh) |
|
994
|
+
| 1 | [simlu](https://github.com/simlu) |
|
995
|
+
| 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
|
996
|
+
| 1 | [yvele](https://github.com/yvele) |
|
992
997
|
|
993
998
|
### Author
|
994
|
-
|
995
999
|
**Jon Schlinkert**
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
1000
|
+
+ [GitHub Profile](https://github.com/jonschlinkert)
|
1001
|
+
+ [Twitter Profile](https://twitter.com/jonschlinkert)
|
1002
|
+
+ [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
|
1000
1003
|
|
1001
1004
|
### License
|
1002
|
-
|
1003
|
-
Copyright © 2021, [Jon Schlinkert](https://github.com/jonschlinkert).
|
1005
|
+
Copyright © 2023, [Jon Schlinkert](https://github.com/jonschlinkert).
|
1004
1006
|
Released under the [MIT License](LICENSE).
|
1005
1007
|
|
1006
1008
|
***
|
1007
1009
|
|
1008
|
-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on
|
1010
|
+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on July 12, 2023._
|
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
|
+
|
package/index.js
CHANGED
@@ -4,7 +4,13 @@ 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
|
-
|
7
|
+
|
8
|
+
const isEmptyString = v => v === '' || v === './';
|
9
|
+
const isObject = v => v !== null && typeof v === 'object' && !Array.isArray(v);
|
10
|
+
const hasBraces = v => {
|
11
|
+
const index = v.indexOf('{');
|
12
|
+
return index > -1 && v.indexOf('}', index) > -1;
|
13
|
+
};
|
8
14
|
|
9
15
|
/**
|
10
16
|
* Returns an array of strings that match one or more glob patterns.
|
@@ -28,12 +34,12 @@ const micromatch = (list, patterns, options) => {
|
|
28
34
|
patterns = [].concat(patterns);
|
29
35
|
list = [].concat(list);
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
37
|
+
const omit = new Set();
|
38
|
+
const keep = new Set();
|
39
|
+
const items = new Set();
|
34
40
|
let negatives = 0;
|
35
41
|
|
36
|
-
|
42
|
+
const onResult = state => {
|
37
43
|
items.add(state.output);
|
38
44
|
if (options && options.onResult) {
|
39
45
|
options.onResult(state);
|
@@ -41,14 +47,14 @@ const micromatch = (list, patterns, options) => {
|
|
41
47
|
};
|
42
48
|
|
43
49
|
for (let i = 0; i < patterns.length; i++) {
|
44
|
-
|
45
|
-
|
50
|
+
const isMatch = picomatch(String(patterns[i]), { windows: true, ...options, onResult }, true);
|
51
|
+
const negated = isMatch.state.negated || isMatch.state.negatedExtglob;
|
46
52
|
if (negated) negatives++;
|
47
53
|
|
48
|
-
for (
|
49
|
-
|
54
|
+
for (const item of list) {
|
55
|
+
const matched = isMatch(item, true);
|
50
56
|
|
51
|
-
|
57
|
+
const match = negated ? !matched.isMatch : matched.isMatch;
|
52
58
|
if (!match) continue;
|
53
59
|
|
54
60
|
if (negated) {
|
@@ -60,8 +66,8 @@ const micromatch = (list, patterns, options) => {
|
|
60
66
|
}
|
61
67
|
}
|
62
68
|
|
63
|
-
|
64
|
-
|
69
|
+
const result = negatives === patterns.length ? [...items] : [...keep];
|
70
|
+
const matches = result.filter(item => !omit.has(item));
|
65
71
|
|
66
72
|
if (options && matches.length === 0) {
|
67
73
|
if (options.failglob === true) {
|
@@ -94,14 +100,17 @@ micromatch.match = micromatch;
|
|
94
100
|
* const isMatch = mm.matcher('*.!(*a)');
|
95
101
|
* console.log(isMatch('a.a')); //=> false
|
96
102
|
* console.log(isMatch('a.b')); //=> true
|
103
|
+
*
|
104
|
+
* const isMatch = mm.matcher(['b.*', '*.a']);
|
105
|
+
* console.log(isMatch('a.a')); //=> true
|
97
106
|
* ```
|
98
|
-
* @param {String} `pattern`
|
107
|
+
* @param {String|Array} `pattern` One or more glob patterns to use for matching.
|
99
108
|
* @param {Object} `options`
|
100
109
|
* @return {Function} Returns a matcher function.
|
101
110
|
* @api public
|
102
111
|
*/
|
103
112
|
|
104
|
-
micromatch.matcher = (pattern, options) => picomatch(pattern, options);
|
113
|
+
micromatch.matcher = (pattern, options) => picomatch(pattern, { windows: true, ...options });
|
105
114
|
|
106
115
|
/**
|
107
116
|
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
@@ -147,18 +156,18 @@ micromatch.any = micromatch.isMatch;
|
|
147
156
|
|
148
157
|
micromatch.not = (list, patterns, options = {}) => {
|
149
158
|
patterns = [].concat(patterns).map(String);
|
150
|
-
|
151
|
-
|
159
|
+
const result = new Set();
|
160
|
+
const items = [];
|
152
161
|
|
153
|
-
|
162
|
+
const onResult = state => {
|
154
163
|
if (options.onResult) options.onResult(state);
|
155
164
|
items.push(state.output);
|
156
165
|
};
|
157
166
|
|
158
|
-
|
167
|
+
const matches = new Set(micromatch(list, patterns, { ...options, onResult }));
|
159
168
|
|
160
|
-
for (
|
161
|
-
if (!matches.
|
169
|
+
for (const item of items) {
|
170
|
+
if (!matches.has(item)) {
|
162
171
|
result.add(item);
|
163
172
|
}
|
164
173
|
}
|
@@ -228,12 +237,12 @@ micromatch.contains = (str, pattern, options) => {
|
|
228
237
|
*/
|
229
238
|
|
230
239
|
micromatch.matchKeys = (obj, patterns, options) => {
|
231
|
-
if (!
|
240
|
+
if (!isObject(obj)) {
|
232
241
|
throw new TypeError('Expected the first argument to be an object');
|
233
242
|
}
|
234
|
-
|
235
|
-
|
236
|
-
for (
|
243
|
+
const keys = micromatch(Object.keys(obj), patterns, options);
|
244
|
+
const res = {};
|
245
|
+
for (const key of keys) res[key] = obj[key];
|
237
246
|
return res;
|
238
247
|
};
|
239
248
|
|
@@ -257,10 +266,10 @@ micromatch.matchKeys = (obj, patterns, options) => {
|
|
257
266
|
*/
|
258
267
|
|
259
268
|
micromatch.some = (list, patterns, options) => {
|
260
|
-
|
269
|
+
const items = [].concat(list);
|
261
270
|
|
262
|
-
for (
|
263
|
-
|
271
|
+
for (const pattern of [].concat(patterns)) {
|
272
|
+
const isMatch = picomatch(String(pattern), { windows: true, ...options });
|
264
273
|
if (items.some(item => isMatch(item))) {
|
265
274
|
return true;
|
266
275
|
}
|
@@ -293,10 +302,10 @@ micromatch.some = (list, patterns, options) => {
|
|
293
302
|
*/
|
294
303
|
|
295
304
|
micromatch.every = (list, patterns, options) => {
|
296
|
-
|
305
|
+
const items = [].concat(list);
|
297
306
|
|
298
|
-
for (
|
299
|
-
|
307
|
+
for (const pattern of [].concat(patterns)) {
|
308
|
+
const isMatch = picomatch(String(pattern), { windows: true, ...options });
|
300
309
|
if (!items.every(item => isMatch(item))) {
|
301
310
|
return false;
|
302
311
|
}
|
@@ -336,7 +345,7 @@ micromatch.all = (str, patterns, options) => {
|
|
336
345
|
throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
|
337
346
|
}
|
338
347
|
|
339
|
-
return [].concat(patterns).every(p => picomatch(p, options)(str));
|
348
|
+
return [].concat(patterns).every(p => picomatch(p, { windows: true, ...options })(str));
|
340
349
|
};
|
341
350
|
|
342
351
|
/**
|
@@ -359,9 +368,9 @@ micromatch.all = (str, patterns, options) => {
|
|
359
368
|
*/
|
360
369
|
|
361
370
|
micromatch.capture = (glob, input, options) => {
|
362
|
-
|
363
|
-
|
364
|
-
|
371
|
+
const windows = utils.isWindows(options);
|
372
|
+
const regex = picomatch.makeRe(String(glob), { windows: true, ...options, capture: true });
|
373
|
+
const match = regex.exec(windows ? utils.toPosixSlashes(input) : input);
|
365
374
|
|
366
375
|
if (match) {
|
367
376
|
return match.slice(1).map(v => v === void 0 ? '' : v);
|
@@ -384,7 +393,7 @@ micromatch.capture = (glob, input, options) => {
|
|
384
393
|
* @api public
|
385
394
|
*/
|
386
395
|
|
387
|
-
micromatch.makeRe = (
|
396
|
+
micromatch.makeRe = (pattern, options) => picomatch.makeRe(pattern, { windows: true, ...options });
|
388
397
|
|
389
398
|
/**
|
390
399
|
* Scan a glob pattern to separate the pattern into segments. Used
|
@@ -400,7 +409,7 @@ micromatch.makeRe = (...args) => picomatch.makeRe(...args);
|
|
400
409
|
* @api public
|
401
410
|
*/
|
402
411
|
|
403
|
-
micromatch.scan = (
|
412
|
+
micromatch.scan = (pattern, options) => picomatch.scan(pattern, { windows: true, ...options });
|
404
413
|
|
405
414
|
/**
|
406
415
|
* Parse a glob pattern to create the source string for a regular
|
@@ -408,7 +417,7 @@ micromatch.scan = (...args) => picomatch.scan(...args);
|
|
408
417
|
*
|
409
418
|
* ```js
|
410
419
|
* const mm = require('micromatch');
|
411
|
-
* const state = mm(pattern[, options]);
|
420
|
+
* const state = mm.parse(pattern[, options]);
|
412
421
|
* ```
|
413
422
|
* @param {String} `glob`
|
414
423
|
* @param {Object} `options`
|
@@ -417,10 +426,10 @@ micromatch.scan = (...args) => picomatch.scan(...args);
|
|
417
426
|
*/
|
418
427
|
|
419
428
|
micromatch.parse = (patterns, options) => {
|
420
|
-
|
421
|
-
for (
|
422
|
-
for (
|
423
|
-
res.push(picomatch.parse(str, options));
|
429
|
+
const res = [];
|
430
|
+
for (const pattern of [].concat(patterns || [])) {
|
431
|
+
for (const str of braces(String(pattern), options)) {
|
432
|
+
res.push(picomatch.parse(str, { windows: utils.isWindows(), ...options }));
|
424
433
|
}
|
425
434
|
}
|
426
435
|
return res;
|
@@ -445,7 +454,7 @@ micromatch.parse = (patterns, options) => {
|
|
445
454
|
|
446
455
|
micromatch.braces = (pattern, options) => {
|
447
456
|
if (typeof pattern !== 'string') throw new TypeError('Expected a string');
|
448
|
-
if ((options && options.nobrace === true) ||
|
457
|
+
if ((options && options.nobrace === true) || !hasBraces(pattern)) {
|
449
458
|
return [pattern];
|
450
459
|
}
|
451
460
|
return braces(pattern, options);
|
@@ -464,4 +473,6 @@ micromatch.braceExpand = (pattern, options) => {
|
|
464
473
|
* Expose micromatch
|
465
474
|
*/
|
466
475
|
|
476
|
+
// exposed for tests
|
477
|
+
micromatch.hasBraces = hasBraces;
|
467
478
|
module.exports = micromatch;
|
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.6",
|
5
5
|
"homepage": "https://github.com/micromatch/micromatch",
|
6
6
|
"author": "Jon Schlinkert (https://github.com/jonschlinkert)",
|
7
7
|
"contributors": [
|
@@ -37,14 +37,14 @@
|
|
37
37
|
"test": "mocha"
|
38
38
|
},
|
39
39
|
"dependencies": {
|
40
|
-
"braces": "^3.0.
|
41
|
-
"picomatch": "^
|
40
|
+
"braces": "^3.0.3",
|
41
|
+
"picomatch": "^4.0.2"
|
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": "^9.0.3",
|
47
|
+
"mocha": "^10.4.0",
|
48
48
|
"time-require": "github:jonschlinkert/time-require"
|
49
49
|
},
|
50
50
|
"keywords": [
|
package/CHANGELOG.md
DELETED
@@ -1,109 +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
|
-
- Require Node.js >= 8.6
|
47
|
-
- Removed support for passing an array of brace patterns to `micromatch.braces()`.
|
48
|
-
- To strictly enforce closing brackets (for `{`, `[`, and `(`), you must now use `strictBrackets=true` instead of `strictErrors`.
|
49
|
-
- `cache` - caching and all related options and methods have been removed
|
50
|
-
- `options.unixify` was renamed to `options.windows`
|
51
|
-
- `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.
|
52
|
-
- `options.snapdragon` was removed, as snapdragon is no longer used.
|
53
|
-
- `options.sourcemap` was removed, as snapdragon is no longer used, which provided sourcemap support.
|
54
|
-
|
55
|
-
## [3.0.0] - 2017-04-11
|
56
|
-
|
57
|
-
Complete overhaul, with 36,000+ new unit tests validated against actual output generated by Bash and minimatch. More specifically, 35,000+ of the tests:
|
58
|
-
|
59
|
-
- micromatch results are directly compared to bash results
|
60
|
-
- in rare cases, when micromatch and bash disagree, micromatch's results are compared to minimatch's results
|
61
|
-
- micromatch is much more accurate than minimatch, so there were cases where I had to make assumptions. I'll try to document these.
|
62
|
-
|
63
|
-
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.
|
64
|
-
|
65
|
-
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.
|
66
|
-
|
67
|
-
Here are those sub-modules with links to related prs on those modules if you want to see how they contribute to this code:
|
68
|
-
|
69
|
-
[nanomatch](https://github.com/jonschlinkert/nanomatch) (new library) - glob expansion (`*`, `**`, `?` and `[...]`))
|
70
|
-
[braces](https://github.com/jonschlinkert/braces/pull/10) - brace expansion (`{1..10}`, `{a,b,c}`, etc)
|
71
|
-
[extglob](https://github.com/jonschlinkert/extglob/pull/5) - extended globs (`!(a|b)`, `@(!(foo|bar))`, etc)
|
72
|
-
[expand-brackets](https://github.com/jonschlinkert/expand-brackets/pull/5) - POSIX character classes `[[:alpha:][:digit:]]`
|
73
|
-
|
74
|
-
**Added**
|
75
|
-
|
76
|
-
- 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).
|
77
|
-
- parser is exposed, so that implementors can customize or override specific micromatch parsers if necessary
|
78
|
-
- compiler is exposed, so that implementors can customize or override specific micromatch compilers if necessary
|
79
|
-
|
80
|
-
**Fixed**
|
81
|
-
|
82
|
-
- 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)
|
83
|
-
- 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
|
84
|
-
|
85
|
-
**Changed**
|
86
|
-
|
87
|
-
- 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:
|
88
|
-
- out of an abundance of caution due to the large amount of code changed in this release
|
89
|
-
- 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
|
90
|
-
|
91
|
-
## [1.0.1] - 2016-12-12
|
92
|
-
|
93
|
-
**Added**
|
94
|
-
|
95
|
-
- Support for windows path edge cases where backslashes are used in brackets or other unusual combinations.
|
96
|
-
|
97
|
-
## [1.0.0] - 2016-12-12
|
98
|
-
|
99
|
-
Stable release.
|
100
|
-
|
101
|
-
## [0.1.0] - 2016-10-08
|
102
|
-
|
103
|
-
First release.
|
104
|
-
|
105
|
-
|
106
|
-
[Unreleased]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...HEAD
|
107
|
-
[0.2.0]: https://github.com/jonschlinkert/micromatch/compare/0.1.0...0.2.0
|
108
|
-
|
109
|
-
[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
|