minimatch 0.2.12 → 0.4.0
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/.npmignore +1 -0
- package/README.md +40 -40
- package/minimatch.js +83 -89
- package/package.json +2 -2
- package/test/brace-expand.js +7 -0
- package/test/defaults.js +1 -1
- package/test/extglob-ending-with-state-char.js +8 -0
package/.npmignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
node_modules
|
package/README.md
CHANGED
|
@@ -19,6 +19,7 @@ var minimatch = require("minimatch")
|
|
|
19
19
|
|
|
20
20
|
minimatch("bar.foo", "*.foo") // true!
|
|
21
21
|
minimatch("bar.foo", "*.bar") // false!
|
|
22
|
+
minimatch("bar.foo", "*.+(bar|foo)", { debug: true }) // true, and noisy!
|
|
22
23
|
```
|
|
23
24
|
|
|
24
25
|
## Features
|
|
@@ -36,44 +37,6 @@ See:
|
|
|
36
37
|
* `man 3 fnmatch`
|
|
37
38
|
* `man 5 gitignore`
|
|
38
39
|
|
|
39
|
-
### Comparisons to other fnmatch/glob implementations
|
|
40
|
-
|
|
41
|
-
While strict compliance with the existing standards is a worthwhile
|
|
42
|
-
goal, some discrepancies exist between minimatch and other
|
|
43
|
-
implementations, and are intentional.
|
|
44
|
-
|
|
45
|
-
If the pattern starts with a `!` character, then it is negated. Set the
|
|
46
|
-
`nonegate` flag to suppress this behavior, and treat leading `!`
|
|
47
|
-
characters normally. This is perhaps relevant if you wish to start the
|
|
48
|
-
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
|
|
49
|
-
characters at the start of a pattern will negate the pattern multiple
|
|
50
|
-
times.
|
|
51
|
-
|
|
52
|
-
If a pattern starts with `#`, then it is treated as a comment, and
|
|
53
|
-
will not match anything. Use `\#` to match a literal `#` at the
|
|
54
|
-
start of a line, or set the `nocomment` flag to suppress this behavior.
|
|
55
|
-
|
|
56
|
-
The double-star character `**` is supported by default, unless the
|
|
57
|
-
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
|
58
|
-
and bash 4.1, where `**` only has special significance if it is the only
|
|
59
|
-
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
|
60
|
-
`a/**b` will not. **Note that this is different from the way that `**` is
|
|
61
|
-
handled by ruby's `Dir` class.**
|
|
62
|
-
|
|
63
|
-
If an escaped pattern has no matches, and the `nonull` flag is set,
|
|
64
|
-
then minimatch.match returns the pattern as-provided, rather than
|
|
65
|
-
interpreting the character escapes. For example,
|
|
66
|
-
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
|
67
|
-
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
|
68
|
-
that it does not resolve escaped pattern characters.
|
|
69
|
-
|
|
70
|
-
If brace expansion is not disabled, then it is performed before any
|
|
71
|
-
other interpretation of the glob pattern. Thus, a pattern like
|
|
72
|
-
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
|
73
|
-
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
|
74
|
-
checked for validity. Since those two are valid, matching proceeds.
|
|
75
|
-
|
|
76
|
-
|
|
77
40
|
## Minimatch Class
|
|
78
41
|
|
|
79
42
|
Create a minimatch object by instanting the `minimatch.Minimatch` class.
|
|
@@ -194,8 +157,8 @@ Perform a case-insensitive match.
|
|
|
194
157
|
### nonull
|
|
195
158
|
|
|
196
159
|
When a match is not found by `minimatch.match`, return a list containing
|
|
197
|
-
the pattern itself. When set, an empty list
|
|
198
|
-
no matches.
|
|
160
|
+
the pattern itself if this option is set. When not set, an empty list
|
|
161
|
+
is returned if there are no matches.
|
|
199
162
|
|
|
200
163
|
### matchBase
|
|
201
164
|
|
|
@@ -216,3 +179,40 @@ Suppress the behavior of treating a leading `!` character as negation.
|
|
|
216
179
|
|
|
217
180
|
Returns from negate expressions the same as if they were not negated.
|
|
218
181
|
(Ie, true on a hit, false on a miss.)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
## Comparisons to other fnmatch/glob implementations
|
|
185
|
+
|
|
186
|
+
While strict compliance with the existing standards is a worthwhile
|
|
187
|
+
goal, some discrepancies exist between minimatch and other
|
|
188
|
+
implementations, and are intentional.
|
|
189
|
+
|
|
190
|
+
If the pattern starts with a `!` character, then it is negated. Set the
|
|
191
|
+
`nonegate` flag to suppress this behavior, and treat leading `!`
|
|
192
|
+
characters normally. This is perhaps relevant if you wish to start the
|
|
193
|
+
pattern with a negative extglob pattern like `!(a|B)`. Multiple `!`
|
|
194
|
+
characters at the start of a pattern will negate the pattern multiple
|
|
195
|
+
times.
|
|
196
|
+
|
|
197
|
+
If a pattern starts with `#`, then it is treated as a comment, and
|
|
198
|
+
will not match anything. Use `\#` to match a literal `#` at the
|
|
199
|
+
start of a line, or set the `nocomment` flag to suppress this behavior.
|
|
200
|
+
|
|
201
|
+
The double-star character `**` is supported by default, unless the
|
|
202
|
+
`noglobstar` flag is set. This is supported in the manner of bsdglob
|
|
203
|
+
and bash 4.1, where `**` only has special significance if it is the only
|
|
204
|
+
thing in a path part. That is, `a/**/b` will match `a/x/y/b`, but
|
|
205
|
+
`a/**b` will not.
|
|
206
|
+
|
|
207
|
+
If an escaped pattern has no matches, and the `nonull` flag is set,
|
|
208
|
+
then minimatch.match returns the pattern as-provided, rather than
|
|
209
|
+
interpreting the character escapes. For example,
|
|
210
|
+
`minimatch.match([], "\\*a\\?")` will return `"\\*a\\?"` rather than
|
|
211
|
+
`"*a?"`. This is akin to setting the `nullglob` option in bash, except
|
|
212
|
+
that it does not resolve escaped pattern characters.
|
|
213
|
+
|
|
214
|
+
If brace expansion is not disabled, then it is performed before any
|
|
215
|
+
other interpretation of the glob pattern. Thus, a pattern like
|
|
216
|
+
`+(a|{b),c)}`, which would not be valid in bash or zsh, is expanded
|
|
217
|
+
**first** into the set of `+(a|b)` and `+(a|c)`, and those patterns are
|
|
218
|
+
checked for validity. Since those two are valid, matching proceeds.
|
package/minimatch.js
CHANGED
|
@@ -68,17 +68,6 @@ function charSet (s) {
|
|
|
68
68
|
// normalizes slashes.
|
|
69
69
|
var slashSplit = /\/+/
|
|
70
70
|
|
|
71
|
-
minimatch.monkeyPatch = monkeyPatch
|
|
72
|
-
function monkeyPatch () {
|
|
73
|
-
var desc = Object.getOwnPropertyDescriptor(String.prototype, "match")
|
|
74
|
-
var orig = desc.value
|
|
75
|
-
desc.value = function (p) {
|
|
76
|
-
if (p instanceof Minimatch) return p.match(this)
|
|
77
|
-
return orig.call(this, p)
|
|
78
|
-
}
|
|
79
|
-
Object.defineProperty(String.prototype, desc)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
71
|
minimatch.filter = filter
|
|
83
72
|
function filter (pattern, options) {
|
|
84
73
|
options = options || {}
|
|
@@ -178,6 +167,8 @@ function Minimatch (pattern, options) {
|
|
|
178
167
|
this.make()
|
|
179
168
|
}
|
|
180
169
|
|
|
170
|
+
Minimatch.prototype.debug = function() {}
|
|
171
|
+
|
|
181
172
|
Minimatch.prototype.make = make
|
|
182
173
|
function make () {
|
|
183
174
|
// don't do it more than once.
|
|
@@ -202,7 +193,9 @@ function make () {
|
|
|
202
193
|
// step 2: expand braces
|
|
203
194
|
var set = this.globSet = this.braceExpand()
|
|
204
195
|
|
|
205
|
-
if (options.debug) console.error
|
|
196
|
+
if (options.debug) this.debug = console.error
|
|
197
|
+
|
|
198
|
+
this.debug(this.pattern, set)
|
|
206
199
|
|
|
207
200
|
// step 3: now we have a set, so turn each one into a series of path-portion
|
|
208
201
|
// matching patterns.
|
|
@@ -213,21 +206,21 @@ function make () {
|
|
|
213
206
|
return s.split(slashSplit)
|
|
214
207
|
})
|
|
215
208
|
|
|
216
|
-
|
|
209
|
+
this.debug(this.pattern, set)
|
|
217
210
|
|
|
218
211
|
// glob --> regexps
|
|
219
212
|
set = set.map(function (s, si, set) {
|
|
220
213
|
return s.map(this.parse, this)
|
|
221
214
|
}, this)
|
|
222
215
|
|
|
223
|
-
|
|
216
|
+
this.debug(this.pattern, set)
|
|
224
217
|
|
|
225
218
|
// filter out everything that didn't compile properly.
|
|
226
219
|
set = set.filter(function (s) {
|
|
227
220
|
return -1 === s.indexOf(false)
|
|
228
221
|
})
|
|
229
222
|
|
|
230
|
-
|
|
223
|
+
this.debug(this.pattern, set)
|
|
231
224
|
|
|
232
225
|
this.set = set
|
|
233
226
|
}
|
|
@@ -267,6 +260,13 @@ minimatch.braceExpand = function (pattern, options) {
|
|
|
267
260
|
}
|
|
268
261
|
|
|
269
262
|
Minimatch.prototype.braceExpand = braceExpand
|
|
263
|
+
|
|
264
|
+
function pad(n, width, z) {
|
|
265
|
+
z = z || '0';
|
|
266
|
+
n = n + '';
|
|
267
|
+
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
270
|
function braceExpand (pattern, options) {
|
|
271
271
|
options = options || this.options
|
|
272
272
|
pattern = typeof pattern === "undefined"
|
|
@@ -302,11 +302,11 @@ function braceExpand (pattern, options) {
|
|
|
302
302
|
// So, we pluck that off, and work with the rest,
|
|
303
303
|
// and then prepend it to everything we find.
|
|
304
304
|
if (pattern.charAt(0) !== "{") {
|
|
305
|
-
|
|
305
|
+
this.debug(pattern)
|
|
306
306
|
var prefix = null
|
|
307
307
|
for (var i = 0, l = pattern.length; i < l; i ++) {
|
|
308
308
|
var c = pattern.charAt(i)
|
|
309
|
-
|
|
309
|
+
this.debug(i, c)
|
|
310
310
|
if (c === "\\") {
|
|
311
311
|
escaping = !escaping
|
|
312
312
|
} else if (c === "{" && !escaping) {
|
|
@@ -317,11 +317,11 @@ function braceExpand (pattern, options) {
|
|
|
317
317
|
|
|
318
318
|
// actually no sets, all { were escaped.
|
|
319
319
|
if (prefix === null) {
|
|
320
|
-
|
|
320
|
+
this.debug("no sets")
|
|
321
321
|
return [pattern]
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
-
|
|
324
|
+
var tail = braceExpand.call(this, pattern.substr(i), options)
|
|
325
325
|
return tail.map(function (t) {
|
|
326
326
|
return prefix + t
|
|
327
327
|
})
|
|
@@ -336,16 +336,21 @@ function braceExpand (pattern, options) {
|
|
|
336
336
|
// first, handle numeric sets, since they're easier
|
|
337
337
|
var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/)
|
|
338
338
|
if (numset) {
|
|
339
|
-
|
|
340
|
-
var suf = braceExpand(pattern.substr(numset[0].length), options)
|
|
339
|
+
this.debug("numset", numset[1], numset[2])
|
|
340
|
+
var suf = braceExpand.call(this, pattern.substr(numset[0].length), options)
|
|
341
341
|
, start = +numset[1]
|
|
342
|
+
, needPadding = numset[1][0] === '0'
|
|
343
|
+
, startWidth = numset[1].length
|
|
344
|
+
, padded
|
|
342
345
|
, end = +numset[2]
|
|
343
346
|
, inc = start > end ? -1 : 1
|
|
344
347
|
, set = []
|
|
348
|
+
|
|
345
349
|
for (var i = start; i != (end + inc); i += inc) {
|
|
350
|
+
padded = needPadding ? pad(i, startWidth) : i + ''
|
|
346
351
|
// append all the suffixes
|
|
347
352
|
for (var ii = 0, ll = suf.length; ii < ll; ii ++) {
|
|
348
|
-
set.push(
|
|
353
|
+
set.push(padded + suf[ii])
|
|
349
354
|
}
|
|
350
355
|
}
|
|
351
356
|
return set
|
|
@@ -369,10 +374,10 @@ function braceExpand (pattern, options) {
|
|
|
369
374
|
member = ""
|
|
370
375
|
}
|
|
371
376
|
|
|
372
|
-
|
|
377
|
+
this.debug("Entering for")
|
|
373
378
|
FOR: for (i = 1, l = pattern.length; i < l; i ++) {
|
|
374
379
|
var c = pattern.charAt(i)
|
|
375
|
-
|
|
380
|
+
this.debug("", i, c)
|
|
376
381
|
|
|
377
382
|
if (escaping) {
|
|
378
383
|
escaping = false
|
|
@@ -420,22 +425,22 @@ function braceExpand (pattern, options) {
|
|
|
420
425
|
// pattern.substr(i), or we have *not* closed the set,
|
|
421
426
|
// and need to escape the leading brace
|
|
422
427
|
if (depth !== 0) {
|
|
423
|
-
|
|
424
|
-
return braceExpand("\\" + pattern, options)
|
|
428
|
+
this.debug("didn't close", pattern)
|
|
429
|
+
return braceExpand.call(this, "\\" + pattern, options)
|
|
425
430
|
}
|
|
426
431
|
|
|
427
432
|
// x{y,z} -> ["xy", "xz"]
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
var suf = braceExpand(pattern.substr(i), options)
|
|
433
|
+
this.debug("set", set)
|
|
434
|
+
this.debug("suffix", pattern.substr(i))
|
|
435
|
+
var suf = braceExpand.call(this, pattern.substr(i), options)
|
|
431
436
|
// ["b", "c{d,e}","{f,g}h"] ->
|
|
432
437
|
// [["b"], ["cd", "ce"], ["fh", "gh"]]
|
|
433
438
|
var addBraces = set.length === 1
|
|
434
|
-
|
|
439
|
+
this.debug("set pre-expanded", set)
|
|
435
440
|
set = set.map(function (p) {
|
|
436
|
-
return braceExpand(p, options)
|
|
437
|
-
})
|
|
438
|
-
|
|
441
|
+
return braceExpand.call(this, p, options)
|
|
442
|
+
}, this)
|
|
443
|
+
this.debug("set expanded", set)
|
|
439
444
|
|
|
440
445
|
|
|
441
446
|
// [["b"], ["cd", "ce"], ["fh", "gh"]] ->
|
|
@@ -496,6 +501,7 @@ function parse (pattern, isSub) {
|
|
|
496
501
|
// not (start or / followed by . or .. followed by / or end)
|
|
497
502
|
: options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"
|
|
498
503
|
: "(?!\\.)"
|
|
504
|
+
, self = this
|
|
499
505
|
|
|
500
506
|
function clearStateChar () {
|
|
501
507
|
if (stateChar) {
|
|
@@ -514,6 +520,7 @@ function parse (pattern, isSub) {
|
|
|
514
520
|
re += "\\"+stateChar
|
|
515
521
|
break
|
|
516
522
|
}
|
|
523
|
+
self.debug('clearStateChar %j %j', stateChar, re)
|
|
517
524
|
stateChar = false
|
|
518
525
|
}
|
|
519
526
|
}
|
|
@@ -522,9 +529,7 @@ function parse (pattern, isSub) {
|
|
|
522
529
|
; (i < len) && (c = pattern.charAt(i))
|
|
523
530
|
; i ++ ) {
|
|
524
531
|
|
|
525
|
-
|
|
526
|
-
console.error("%s\t%s %s %j", pattern, i, re, c)
|
|
527
|
-
}
|
|
532
|
+
this.debug("%s\t%s %s %j", pattern, i, re, c)
|
|
528
533
|
|
|
529
534
|
// skip over any that are escaped.
|
|
530
535
|
if (escaping && reSpecials[c]) {
|
|
@@ -551,13 +556,12 @@ function parse (pattern, isSub) {
|
|
|
551
556
|
case "+":
|
|
552
557
|
case "@":
|
|
553
558
|
case "!":
|
|
554
|
-
|
|
555
|
-
console.error("%s\t%s %s %j <-- stateChar", pattern, i, re, c)
|
|
556
|
-
}
|
|
559
|
+
this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)
|
|
557
560
|
|
|
558
561
|
// all of those are literals inside a class, except that
|
|
559
562
|
// the glob [!a] means [^a] in regexp
|
|
560
563
|
if (inClass) {
|
|
564
|
+
this.debug(' in class')
|
|
561
565
|
if (c === "!" && i === classStart + 1) c = "^"
|
|
562
566
|
re += c
|
|
563
567
|
continue
|
|
@@ -566,6 +570,7 @@ function parse (pattern, isSub) {
|
|
|
566
570
|
// if we already have a stateChar, then it means
|
|
567
571
|
// that there was something like ** or +? in there.
|
|
568
572
|
// Handle the stateChar, then proceed with this one.
|
|
573
|
+
self.debug('call clearStateChar %j', stateChar)
|
|
569
574
|
clearStateChar()
|
|
570
575
|
stateChar = c
|
|
571
576
|
// if extglob is disabled, then +(asdf|foo) isn't a thing.
|
|
@@ -591,6 +596,7 @@ function parse (pattern, isSub) {
|
|
|
591
596
|
, reStart: re.length })
|
|
592
597
|
// negation is (?:(?!js)[^/]*)
|
|
593
598
|
re += stateChar === "!" ? "(?:(?!" : "(?:"
|
|
599
|
+
this.debug('plType %j %j', stateChar, re)
|
|
594
600
|
stateChar = false
|
|
595
601
|
continue
|
|
596
602
|
|
|
@@ -600,6 +606,7 @@ function parse (pattern, isSub) {
|
|
|
600
606
|
continue
|
|
601
607
|
}
|
|
602
608
|
|
|
609
|
+
clearStateChar()
|
|
603
610
|
hasMagic = true
|
|
604
611
|
re += ")"
|
|
605
612
|
plType = patternListStack.pop().type
|
|
@@ -623,6 +630,7 @@ function parse (pattern, isSub) {
|
|
|
623
630
|
continue
|
|
624
631
|
}
|
|
625
632
|
|
|
633
|
+
clearStateChar()
|
|
626
634
|
re += "|"
|
|
627
635
|
continue
|
|
628
636
|
|
|
@@ -715,7 +723,7 @@ function parse (pattern, isSub) {
|
|
|
715
723
|
return $1 + $1 + $2 + "|"
|
|
716
724
|
})
|
|
717
725
|
|
|
718
|
-
|
|
726
|
+
this.debug("tail=%j\n %s", tail, tail)
|
|
719
727
|
var t = pl.type === "*" ? star
|
|
720
728
|
: pl.type === "?" ? qmark
|
|
721
729
|
: "\\" + pl.type
|
|
@@ -817,11 +825,12 @@ function makeRe () {
|
|
|
817
825
|
}
|
|
818
826
|
|
|
819
827
|
minimatch.match = function (list, pattern, options) {
|
|
828
|
+
options = options || {}
|
|
820
829
|
var mm = new Minimatch(pattern, options)
|
|
821
830
|
list = list.filter(function (f) {
|
|
822
831
|
return mm.match(f)
|
|
823
832
|
})
|
|
824
|
-
if (options.nonull && !list.length) {
|
|
833
|
+
if (mm.options.nonull && !list.length) {
|
|
825
834
|
list.push(pattern)
|
|
826
835
|
}
|
|
827
836
|
return list
|
|
@@ -829,7 +838,7 @@ minimatch.match = function (list, pattern, options) {
|
|
|
829
838
|
|
|
830
839
|
Minimatch.prototype.match = match
|
|
831
840
|
function match (f, partial) {
|
|
832
|
-
|
|
841
|
+
this.debug("match", f, this.pattern)
|
|
833
842
|
// short-circuit in the case of busted things.
|
|
834
843
|
// comments, etc.
|
|
835
844
|
if (this.comment) return false
|
|
@@ -847,9 +856,7 @@ function match (f, partial) {
|
|
|
847
856
|
|
|
848
857
|
// treat the test path as a set of pathparts.
|
|
849
858
|
f = f.split(slashSplit)
|
|
850
|
-
|
|
851
|
-
console.error(this.pattern, "split", f)
|
|
852
|
-
}
|
|
859
|
+
this.debug(this.pattern, "split", f)
|
|
853
860
|
|
|
854
861
|
// just ONE of the pattern sets in this.set needs to match
|
|
855
862
|
// in order for it to be valid. If negating, then just one
|
|
@@ -857,11 +864,21 @@ function match (f, partial) {
|
|
|
857
864
|
// Either way, return on the first hit.
|
|
858
865
|
|
|
859
866
|
var set = this.set
|
|
860
|
-
|
|
867
|
+
this.debug(this.pattern, "set", set)
|
|
868
|
+
|
|
869
|
+
// Find the basename of the path by looking for the last non-empty segment
|
|
870
|
+
var filename;
|
|
871
|
+
for (var i = f.length - 1; i >= 0; i--) {
|
|
872
|
+
filename = f[i]
|
|
873
|
+
if (filename) break
|
|
874
|
+
}
|
|
861
875
|
|
|
862
876
|
for (var i = 0, l = set.length; i < l; i ++) {
|
|
863
|
-
var pattern = set[i]
|
|
864
|
-
|
|
877
|
+
var pattern = set[i], file = f
|
|
878
|
+
if (options.matchBase && pattern.length === 1) {
|
|
879
|
+
file = [filename]
|
|
880
|
+
}
|
|
881
|
+
var hit = this.matchOne(file, pattern, partial)
|
|
865
882
|
if (hit) {
|
|
866
883
|
if (options.flipNegate) return true
|
|
867
884
|
return !this.negate
|
|
@@ -882,20 +899,12 @@ function match (f, partial) {
|
|
|
882
899
|
Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
883
900
|
var options = this.options
|
|
884
901
|
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
, pattern: pattern })
|
|
890
|
-
}
|
|
891
|
-
|
|
892
|
-
if (options.matchBase && pattern.length === 1) {
|
|
893
|
-
file = path.basename(file.join("/")).split("/")
|
|
894
|
-
}
|
|
902
|
+
this.debug("matchOne",
|
|
903
|
+
{ "this": this
|
|
904
|
+
, file: file
|
|
905
|
+
, pattern: pattern })
|
|
895
906
|
|
|
896
|
-
|
|
897
|
-
console.error("matchOne", file.length, pattern.length)
|
|
898
|
-
}
|
|
907
|
+
this.debug("matchOne", file.length, pattern.length)
|
|
899
908
|
|
|
900
909
|
for ( var fi = 0
|
|
901
910
|
, pi = 0
|
|
@@ -904,23 +913,18 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
904
913
|
; (fi < fl) && (pi < pl)
|
|
905
914
|
; fi ++, pi ++ ) {
|
|
906
915
|
|
|
907
|
-
|
|
908
|
-
console.error("matchOne loop")
|
|
909
|
-
}
|
|
916
|
+
this.debug("matchOne loop")
|
|
910
917
|
var p = pattern[pi]
|
|
911
918
|
, f = file[fi]
|
|
912
919
|
|
|
913
|
-
|
|
914
|
-
console.error(pattern, p, f)
|
|
915
|
-
}
|
|
920
|
+
this.debug(pattern, p, f)
|
|
916
921
|
|
|
917
922
|
// should be impossible.
|
|
918
923
|
// some invalid regexp stuff in the set.
|
|
919
924
|
if (p === false) return false
|
|
920
925
|
|
|
921
926
|
if (p === GLOBSTAR) {
|
|
922
|
-
|
|
923
|
-
console.error('GLOBSTAR', [pattern, p, f])
|
|
927
|
+
this.debug('GLOBSTAR', [pattern, p, f])
|
|
924
928
|
|
|
925
929
|
// "**"
|
|
926
930
|
// a/**/b/**/c would match the following:
|
|
@@ -947,8 +951,7 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
947
951
|
var fr = fi
|
|
948
952
|
, pr = pi + 1
|
|
949
953
|
if (pr === pl) {
|
|
950
|
-
|
|
951
|
-
console.error('** at the end')
|
|
954
|
+
this.debug('** at the end')
|
|
952
955
|
// a ** at the end will just swallow the rest.
|
|
953
956
|
// We have found a match.
|
|
954
957
|
// however, it will not swallow /.x, unless
|
|
@@ -966,15 +969,12 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
966
969
|
WHILE: while (fr < fl) {
|
|
967
970
|
var swallowee = file[fr]
|
|
968
971
|
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
file, fr, pattern, pr, swallowee)
|
|
972
|
-
}
|
|
972
|
+
this.debug('\nglobstar while',
|
|
973
|
+
file, fr, pattern, pr, swallowee)
|
|
973
974
|
|
|
974
975
|
// XXX remove this slice. Just pass the start index.
|
|
975
976
|
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
976
|
-
|
|
977
|
-
console.error('globstar found match!', fr, fl, swallowee)
|
|
977
|
+
this.debug('globstar found match!', fr, fl, swallowee)
|
|
978
978
|
// found a match.
|
|
979
979
|
return true
|
|
980
980
|
} else {
|
|
@@ -982,23 +982,21 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
982
982
|
// can only swallow ".foo" when explicitly asked.
|
|
983
983
|
if (swallowee === "." || swallowee === ".." ||
|
|
984
984
|
(!options.dot && swallowee.charAt(0) === ".")) {
|
|
985
|
-
|
|
986
|
-
console.error("dot detected!", file, fr, pattern, pr)
|
|
985
|
+
this.debug("dot detected!", file, fr, pattern, pr)
|
|
987
986
|
break WHILE
|
|
988
987
|
}
|
|
989
988
|
|
|
990
989
|
// ** swallows a segment, and continue.
|
|
991
|
-
|
|
992
|
-
console.error('globstar swallow a segment, and continue')
|
|
990
|
+
this.debug('globstar swallow a segment, and continue')
|
|
993
991
|
fr ++
|
|
994
992
|
}
|
|
995
993
|
}
|
|
996
994
|
// no match was found.
|
|
997
995
|
// However, in partial mode, we can't say this is necessarily over.
|
|
998
|
-
// If there's more *pattern* left, then
|
|
996
|
+
// If there's more *pattern* left, then
|
|
999
997
|
if (partial) {
|
|
1000
998
|
// ran out of file
|
|
1001
|
-
|
|
999
|
+
this.debug("\n>>> no match, partial?", file, fr, pattern, pr)
|
|
1002
1000
|
if (fr === fl) return true
|
|
1003
1001
|
}
|
|
1004
1002
|
return false
|
|
@@ -1014,14 +1012,10 @@ Minimatch.prototype.matchOne = function (file, pattern, partial) {
|
|
|
1014
1012
|
} else {
|
|
1015
1013
|
hit = f === p
|
|
1016
1014
|
}
|
|
1017
|
-
|
|
1018
|
-
console.error("string match", p, f, hit)
|
|
1019
|
-
}
|
|
1015
|
+
this.debug("string match", p, f, hit)
|
|
1020
1016
|
} else {
|
|
1021
1017
|
hit = f.match(p)
|
|
1022
|
-
|
|
1023
|
-
console.error("pattern match", p, f, hit)
|
|
1024
|
-
}
|
|
1018
|
+
this.debug("pattern match", p, f, hit)
|
|
1025
1019
|
}
|
|
1026
1020
|
|
|
1027
1021
|
if (!hit) return false
|
package/package.json
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
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": "0.
|
|
5
|
+
"version": "0.4.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git://github.com/isaacs/minimatch.git"
|
|
9
9
|
},
|
|
10
10
|
"main": "minimatch.js",
|
|
11
11
|
"scripts": {
|
|
12
|
-
"test": "tap test"
|
|
12
|
+
"test": "tap test/*.js"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": "*"
|
package/test/brace-expand.js
CHANGED
|
@@ -21,6 +21,13 @@ tap.test("brace expansion", function (t) {
|
|
|
21
21
|
, "a4b"
|
|
22
22
|
, "a5b" ] ]
|
|
23
23
|
, [ "a{b}c", ["a{b}c"] ]
|
|
24
|
+
, [ "a{00..05}b"
|
|
25
|
+
, ["a00b"
|
|
26
|
+
,"a01b"
|
|
27
|
+
,"a02b"
|
|
28
|
+
,"a03b"
|
|
29
|
+
,"a04b"
|
|
30
|
+
,"a05b" ] ]
|
|
24
31
|
].forEach(function (tc) {
|
|
25
32
|
var p = tc[0]
|
|
26
33
|
, expect = tc[1]
|
package/test/defaults.js
CHANGED