minimatch 4.2.0 → 5.0.1
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/README.md +20 -6
- package/lib/path.js +4 -0
- package/minimatch.js +15 -19
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -35,6 +35,20 @@ See:
|
|
|
35
35
|
* `man 3 fnmatch`
|
|
36
36
|
* `man 5 gitignore`
|
|
37
37
|
|
|
38
|
+
## Windows
|
|
39
|
+
|
|
40
|
+
**Please only use forward-slashes in glob expressions.**
|
|
41
|
+
|
|
42
|
+
Though windows uses either `/` or `\` as its path separator, only `/`
|
|
43
|
+
characters are used by this glob implementation. You must use
|
|
44
|
+
forward-slashes **only** in glob expressions. Back-slashes in patterns
|
|
45
|
+
will always be interpreted as escape characters, not path separators.
|
|
46
|
+
|
|
47
|
+
Note that `\` or `/` _will_ be interpreted as path separators in paths on
|
|
48
|
+
Windows, and will match against `/` in glob expressions.
|
|
49
|
+
|
|
50
|
+
So just always use `/` in patterns.
|
|
51
|
+
|
|
38
52
|
## Minimatch Class
|
|
39
53
|
|
|
40
54
|
Create a minimatch object by instantiating the `minimatch.Minimatch` class.
|
|
@@ -187,12 +201,6 @@ minimatch('/a/b', '/**/d', { partial: true }) // true, might be /a/b/.../d
|
|
|
187
201
|
minimatch('/x/y/z', '/a/**/z', { partial: true }) // false, because x !== a
|
|
188
202
|
```
|
|
189
203
|
|
|
190
|
-
### allowWindowsEscape
|
|
191
|
-
|
|
192
|
-
Windows path separator `\` is by default converted to `/`, which
|
|
193
|
-
prohibits the usage of `\` as a escape character. This flag skips that
|
|
194
|
-
behavior and allows using the escape character.
|
|
195
|
-
|
|
196
204
|
## Comparisons to other fnmatch/glob implementations
|
|
197
205
|
|
|
198
206
|
While strict compliance with the existing standards is a worthwhile
|
|
@@ -228,3 +236,9 @@ other interpretation of the glob pattern. Thus, a pattern like
|
|
|
228
236
|
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
|
229
237
|
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
|
230
238
|
checked for validity. Since those two are valid, matching proceeds.
|
|
239
|
+
|
|
240
|
+
Note that `fnmatch(3)` in libc is an extremely naive string comparison
|
|
241
|
+
matcher, which does not do anything special for slashes. This library is
|
|
242
|
+
designed to be used in glob searching and file walkers, and so it does do
|
|
243
|
+
special things with `/`. Thus, `foo*` will not match `foo/bar` in this
|
|
244
|
+
library, even though it would in `fnmatch(3)`.
|
package/lib/path.js
ADDED
package/minimatch.js
CHANGED
|
@@ -11,9 +11,7 @@ const minimatch = module.exports = (p, pattern, options = {}) => {
|
|
|
11
11
|
|
|
12
12
|
module.exports = minimatch
|
|
13
13
|
|
|
14
|
-
const path =
|
|
15
|
-
sep: '/'
|
|
16
|
-
}
|
|
14
|
+
const path = require('./lib/path.js')
|
|
17
15
|
minimatch.sep = path.sep
|
|
18
16
|
|
|
19
17
|
const GLOBSTAR = Symbol('globstar **')
|
|
@@ -167,11 +165,6 @@ class Minimatch {
|
|
|
167
165
|
|
|
168
166
|
if (!options) options = {}
|
|
169
167
|
|
|
170
|
-
// windows support: need to use /, not \
|
|
171
|
-
if (!options.allowWindowsEscape && path.sep !== '/') {
|
|
172
|
-
pattern = pattern.split(path.sep).join('/')
|
|
173
|
-
}
|
|
174
|
-
|
|
175
168
|
this.options = options
|
|
176
169
|
this.set = []
|
|
177
170
|
this.pattern = pattern
|
|
@@ -472,8 +465,16 @@ class Minimatch {
|
|
|
472
465
|
this.debug('%s\t%s %s %j', pattern, i, re, c)
|
|
473
466
|
|
|
474
467
|
// skip over any that are escaped.
|
|
475
|
-
if (escaping
|
|
476
|
-
|
|
468
|
+
if (escaping) {
|
|
469
|
+
/* istanbul ignore next - completely not allowed, even escaped. */
|
|
470
|
+
if (c === '/') {
|
|
471
|
+
return false
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
if (reSpecials[c]) {
|
|
475
|
+
re += '\\'
|
|
476
|
+
}
|
|
477
|
+
re += c
|
|
477
478
|
escaping = false
|
|
478
479
|
continue
|
|
479
480
|
}
|
|
@@ -481,7 +482,6 @@ class Minimatch {
|
|
|
481
482
|
switch (c) {
|
|
482
483
|
/* istanbul ignore next */
|
|
483
484
|
case '/': {
|
|
484
|
-
// completely not allowed, even escaped.
|
|
485
485
|
// Should already be path-split by now.
|
|
486
486
|
return false
|
|
487
487
|
}
|
|
@@ -564,9 +564,8 @@ class Minimatch {
|
|
|
564
564
|
continue
|
|
565
565
|
|
|
566
566
|
case '|':
|
|
567
|
-
if (inClass || !patternListStack.length
|
|
567
|
+
if (inClass || !patternListStack.length) {
|
|
568
568
|
re += '\\|'
|
|
569
|
-
escaping = false
|
|
570
569
|
continue
|
|
571
570
|
}
|
|
572
571
|
|
|
@@ -597,7 +596,6 @@ class Minimatch {
|
|
|
597
596
|
// first in the list. -- POSIX.2 2.8.3.2
|
|
598
597
|
if (i === classStart + 1 || !inClass) {
|
|
599
598
|
re += '\\' + c
|
|
600
|
-
escaping = false
|
|
601
599
|
continue
|
|
602
600
|
}
|
|
603
601
|
|
|
@@ -632,15 +630,12 @@ class Minimatch {
|
|
|
632
630
|
// swallow any state char that wasn't consumed
|
|
633
631
|
clearStateChar()
|
|
634
632
|
|
|
635
|
-
if (
|
|
636
|
-
// no need
|
|
637
|
-
escaping = false
|
|
638
|
-
} else if (reSpecials[c]
|
|
639
|
-
&& !(c === '^' && inClass)) {
|
|
633
|
+
if (reSpecials[c] && !(c === '^' && inClass)) {
|
|
640
634
|
re += '\\'
|
|
641
635
|
}
|
|
642
636
|
|
|
643
637
|
re += c
|
|
638
|
+
break
|
|
644
639
|
|
|
645
640
|
} // switch
|
|
646
641
|
} // for
|
|
@@ -670,6 +665,7 @@ class Minimatch {
|
|
|
670
665
|
this.debug('setting tail', re, pl)
|
|
671
666
|
// maybe some even number of \, then maybe 1 \, followed by a |
|
|
672
667
|
tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
|
|
668
|
+
/* istanbul ignore else - should already be done */
|
|
673
669
|
if (!$2) {
|
|
674
670
|
// the | isn't already escaped, so escape it.
|
|
675
671
|
$2 = '\\'
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
|
|
3
3
|
"name": "minimatch",
|
|
4
4
|
"description": "a glob matcher in javascript",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "5.0.1",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git://github.com/isaacs/minimatch.git"
|
|
@@ -19,13 +19,14 @@
|
|
|
19
19
|
"node": ">=10"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"brace-expansion": "^
|
|
22
|
+
"brace-expansion": "^2.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"tap": "^15.1.6"
|
|
26
26
|
},
|
|
27
27
|
"license": "ISC",
|
|
28
28
|
"files": [
|
|
29
|
-
"minimatch.js"
|
|
29
|
+
"minimatch.js",
|
|
30
|
+
"lib"
|
|
30
31
|
]
|
|
31
32
|
}
|