micromatch 4.0.5 → 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.

Files changed (4) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +135 -129
  3. package/index.js +51 -40
  4. package/package.json +5 -5
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -9,46 +9,48 @@ Please consider following this project's author, [Jon Schlinkert](https://github
9
9
  <details>
10
10
  <summary><strong>Details</strong></summary>
11
11
 
12
- - [Install](#install)
13
- - [Quickstart](#quickstart)
14
- - [Why use micromatch?](#why-use-micromatch)
15
- * [Matching features](#matching-features)
16
- - [Switching to micromatch](#switching-to-micromatch)
17
- * [From minimatch](#from-minimatch)
18
- * [From multimatch](#from-multimatch)
19
- - [API](#api)
20
- - [Options](#options)
21
- - [Options Examples](#options-examples)
22
- * [options.basename](#optionsbasename)
23
- * [options.bash](#optionsbash)
24
- * [options.expandRange](#optionsexpandrange)
25
- * [options.format](#optionsformat)
26
- * [options.ignore](#optionsignore)
27
- * [options.matchBase](#optionsmatchbase)
28
- * [options.noextglob](#optionsnoextglob)
29
- * [options.nonegate](#optionsnonegate)
30
- * [options.noglobstar](#optionsnoglobstar)
31
- * [options.nonull](#optionsnonull)
32
- * [options.nullglob](#optionsnullglob)
33
- * [options.onIgnore](#optionsonignore)
34
- * [options.onMatch](#optionsonmatch)
35
- * [options.onResult](#optionsonresult)
36
- * [options.posixSlashes](#optionsposixslashes)
37
- * [options.unescape](#optionsunescape)
38
- - [Extended globbing](#extended-globbing)
39
- * [Extglobs](#extglobs)
40
- * [Braces](#braces)
41
- * [Regex character classes](#regex-character-classes)
42
- * [Regex groups](#regex-groups)
43
- * [POSIX bracket expressions](#posix-bracket-expressions)
44
- - [Notes](#notes)
45
- * [Bash 4.3 parity](#bash-43-parity)
46
- * [Backslashes](#backslashes)
47
- - [Benchmarks](#benchmarks)
48
- * [Running benchmarks](#running-benchmarks)
49
- * [Latest results](#latest-results)
50
- - [Contributing](#contributing)
51
- - [About](#about)
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
 
@@ -60,6 +62,14 @@ Install with [npm](https://www.npmjs.com/) (requires [Node.js](https://nodejs.or
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,15 +99,15 @@ 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
- * Supports all of the same matching features as [minimatch](https://github.com/isaacs/minimatch) and [multimatch](https://github.com/sindresorhus/multimatch)
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
- * **Fast & Performant** - Loads in about 5ms and performs [fast matches](#benchmarks).
95
- * **Glob matching** - Using wildcards (`*` and `?`), globstars (`**`) for nested directories
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
- * **Accurate** - Covers more scenarios [than minimatch](https://github.com/yarnpkg/yarn/pull/3339)
98
- * **Well tested** - More than 5,000 [test assertions](./test)
99
- * **Windows support** - More reliable windows support than minimatch and multimatch.
100
- * **[Safe](https://github.com/micromatch/braces#braces-is-safe)** - Micromatch is not subject to DoS with brace patterns like minimatch and multimatch.
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
 
@@ -106,7 +116,7 @@ console.log(micromatch.isMatch('foo', ['b*', 'f*'])) //=> true
106
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](https://github.com/micromatch/braces) (`foo/{1..5}.md`, `bar/{a,b,c}.js`)
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**
@@ -423,13 +421,12 @@ 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](https://github.com/micromatch/braces) library for all available options.
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](https://github.com/isaacs/minimatch) option `matchBase`.
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](https://github.com/jonschlinkert/fill-range) library is ideal for this purpose, or you can use custom code to do whatever you need.
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](https://github.com/isaacs/minimatch) option `nonull`.
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](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.
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](http://www.regular-expressions.info/charclass.html).
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
- * 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_.
815
- * Minimatch converts all backslashes to forward slashes, which means you can't use backslashes to escape any characters in your glob patterns.
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
- * Consistency with bash conventions.
820
- * 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.
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 March 24, 2022 (longer bars are better):
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
- * [research existing issues first](../../issues) (open and closed)
909
- * visit the [GNU Bash documentation](https://www.gnu.org/software/bash/manual/) to see how Bash deals with the pattern
910
- * visit the [minimatch](https://github.com/isaacs/minimatch) documentation to cross-check expected behavior in node.js
911
- * 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.
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
- ## About
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,59 +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
- * [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.")
957
- * [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.")
958
- * [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.")
959
- * [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`")
960
- * [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)")
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
- | **Commits** | **Contributor** |
965
- | --- | --- |
966
- | 512 | [jonschlinkert](https://github.com/jonschlinkert) |
967
- | 12 | [es128](https://github.com/es128) |
968
- | 9 | [danez](https://github.com/danez) |
969
- | 8 | [doowb](https://github.com/doowb) |
970
- | 6 | [paulmillr](https://github.com/paulmillr) |
971
- | 5 | [mrmlnc](https://github.com/mrmlnc) |
972
- | 3 | [DrPizza](https://github.com/DrPizza) |
973
- | 2 | [TrySound](https://github.com/TrySound) |
974
- | 2 | [mceIdo](https://github.com/mceIdo) |
975
- | 2 | [Glazy](https://github.com/Glazy) |
976
- | 2 | [MartinKolarik](https://github.com/MartinKolarik) |
977
- | 2 | [antonyk](https://github.com/antonyk) |
978
- | 2 | [Tvrqvoise](https://github.com/Tvrqvoise) |
979
- | 1 | [amilajack](https://github.com/amilajack) |
980
- | 1 | [Cslove](https://github.com/Cslove) |
981
- | 1 | [devongovett](https://github.com/devongovett) |
982
- | 1 | [DianeLooney](https://github.com/DianeLooney) |
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) |
989
- | 1 | [tomByrer](https://github.com/tomByrer) |
990
- | 1 | [fidian](https://github.com/fidian) |
991
- | 1 | [curbengh](https://github.com/curbengh) |
992
- | 1 | [simlu](https://github.com/simlu) |
993
- | 1 | [wtgtybhertgeghgtwtg](https://github.com/wtgtybhertgeghgtwtg) |
994
- | 1 | [yvele](https://github.com/yvele) |
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) |
995
997
 
996
998
  ### Author
997
-
998
999
  **Jon Schlinkert**
999
-
1000
- * [GitHub Profile](https://github.com/jonschlinkert)
1001
- * [Twitter Profile](https://twitter.com/jonschlinkert)
1002
- * [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)
1003
1003
 
1004
1004
  ### License
1005
-
1006
- Copyright © 2022, [Jon Schlinkert](https://github.com/jonschlinkert).
1005
+ Copyright © 2023, [Jon Schlinkert](https://github.com/jonschlinkert).
1007
1006
  Released under the [MIT License](LICENSE).
1008
1007
 
1009
1008
  ***
1010
1009
 
1011
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on March 24, 2022._
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
- const isEmptyString = val => val === '' || val === './';
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
- let omit = new Set();
32
- let keep = new Set();
33
- let items = new Set();
37
+ const omit = new Set();
38
+ const keep = new Set();
39
+ const items = new Set();
34
40
  let negatives = 0;
35
41
 
36
- let onResult = state => {
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
- let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
45
- let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
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 (let item of list) {
49
- let matched = isMatch(item, true);
54
+ for (const item of list) {
55
+ const matched = isMatch(item, true);
50
56
 
51
- let match = negated ? !matched.isMatch : matched.isMatch;
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
- let result = negatives === patterns.length ? [...items] : [...keep];
64
- let matches = result.filter(item => !omit.has(item));
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` Glob 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,17 +156,17 @@ micromatch.any = micromatch.isMatch;
147
156
 
148
157
  micromatch.not = (list, patterns, options = {}) => {
149
158
  patterns = [].concat(patterns).map(String);
150
- let result = new Set();
151
- let items = [];
159
+ const result = new Set();
160
+ const items = [];
152
161
 
153
- let onResult = state => {
162
+ const onResult = state => {
154
163
  if (options.onResult) options.onResult(state);
155
164
  items.push(state.output);
156
165
  };
157
166
 
158
- let matches = new Set(micromatch(list, patterns, { ...options, onResult }));
167
+ const matches = new Set(micromatch(list, patterns, { ...options, onResult }));
159
168
 
160
- for (let item of items) {
169
+ for (const item of items) {
161
170
  if (!matches.has(item)) {
162
171
  result.add(item);
163
172
  }
@@ -228,12 +237,12 @@ micromatch.contains = (str, pattern, options) => {
228
237
  */
229
238
 
230
239
  micromatch.matchKeys = (obj, patterns, options) => {
231
- if (!utils.isObject(obj)) {
240
+ if (!isObject(obj)) {
232
241
  throw new TypeError('Expected the first argument to be an object');
233
242
  }
234
- let keys = micromatch(Object.keys(obj), patterns, options);
235
- let res = {};
236
- for (let key of keys) res[key] = obj[key];
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
- let items = [].concat(list);
269
+ const items = [].concat(list);
261
270
 
262
- for (let pattern of [].concat(patterns)) {
263
- let isMatch = picomatch(String(pattern), options);
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
- let items = [].concat(list);
305
+ const items = [].concat(list);
297
306
 
298
- for (let pattern of [].concat(patterns)) {
299
- let isMatch = picomatch(String(pattern), options);
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
- let posix = utils.isWindows(options);
363
- let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
364
- let match = regex.exec(posix ? utils.toPosixSlashes(input) : input);
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 = (...args) => picomatch.makeRe(...args);
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 = (...args) => picomatch.scan(...args);
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
@@ -417,10 +426,10 @@ micromatch.scan = (...args) => picomatch.scan(...args);
417
426
  */
418
427
 
419
428
  micromatch.parse = (patterns, options) => {
420
- let res = [];
421
- for (let pattern of [].concat(patterns || [])) {
422
- for (let str of braces(String(pattern), options)) {
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) || !/\{.*\}/.test(pattern)) {
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.5",
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.2",
41
- "picomatch": "^2.3.1"
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": "^5.0.1",
47
- "mocha": "^9.2.2",
46
+ "minimatch": "^9.0.3",
47
+ "mocha": "^10.4.0",
48
48
  "time-require": "github:jonschlinkert/time-require"
49
49
  },
50
50
  "keywords": [