minimatch 4.2.1 → 4.2.3
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/minimatch.js +54 -23
- package/package.json +4 -1
package/minimatch.js
CHANGED
|
@@ -440,11 +440,23 @@ class Minimatch {
|
|
|
440
440
|
let pl
|
|
441
441
|
let sp
|
|
442
442
|
// . and .. never match anything that doesn't start with .,
|
|
443
|
-
// even when options.dot is set.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
443
|
+
// even when options.dot is set. However, if the pattern
|
|
444
|
+
// starts with ., then traversal patterns can match.
|
|
445
|
+
let dotTravAllowed = pattern.charAt(0) === '.'
|
|
446
|
+
let dotFileAllowed = options.dot || dotTravAllowed
|
|
447
|
+
const patternStart = () =>
|
|
448
|
+
dotTravAllowed
|
|
449
|
+
? ''
|
|
450
|
+
: dotFileAllowed
|
|
451
|
+
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
452
|
+
: '(?!\\.)'
|
|
453
|
+
const subPatternStart = (p) =>
|
|
454
|
+
p.charAt(0) === '.'
|
|
455
|
+
? ''
|
|
456
|
+
: options.dot
|
|
457
|
+
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
458
|
+
: '(?!\\.)'
|
|
459
|
+
|
|
448
460
|
|
|
449
461
|
const clearStateChar = () => {
|
|
450
462
|
if (stateChar) {
|
|
@@ -528,7 +540,7 @@ class Minimatch {
|
|
|
528
540
|
if (options.noext) clearStateChar()
|
|
529
541
|
continue
|
|
530
542
|
|
|
531
|
-
case '(':
|
|
543
|
+
case '(': {
|
|
532
544
|
if (inClass) {
|
|
533
545
|
re += '('
|
|
534
546
|
continue
|
|
@@ -539,46 +551,64 @@ class Minimatch {
|
|
|
539
551
|
continue
|
|
540
552
|
}
|
|
541
553
|
|
|
542
|
-
|
|
554
|
+
const plEntry = {
|
|
543
555
|
type: stateChar,
|
|
544
556
|
start: i - 1,
|
|
545
557
|
reStart: re.length,
|
|
546
558
|
open: plTypes[stateChar].open,
|
|
547
|
-
close: plTypes[stateChar].close
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
|
|
559
|
+
close: plTypes[stateChar].close,
|
|
560
|
+
}
|
|
561
|
+
this.debug(this.pattern, '\t', plEntry)
|
|
562
|
+
patternListStack.push(plEntry)
|
|
563
|
+
// negation is (?:(?!(?:js)(?:<rest>))[^/]*)
|
|
564
|
+
re += plEntry.open
|
|
565
|
+
// next entry starts with a dot maybe?
|
|
566
|
+
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
567
|
+
dotTravAllowed = true
|
|
568
|
+
re += subPatternStart(pattern.slice(i + 1))
|
|
569
|
+
}
|
|
551
570
|
this.debug('plType %j %j', stateChar, re)
|
|
552
571
|
stateChar = false
|
|
553
|
-
|
|
572
|
+
continue
|
|
573
|
+
}
|
|
554
574
|
|
|
555
|
-
case ')':
|
|
556
|
-
|
|
575
|
+
case ')': {
|
|
576
|
+
const plEntry = patternListStack[patternListStack.length - 1]
|
|
577
|
+
if (inClass || !plEntry) {
|
|
557
578
|
re += '\\)'
|
|
558
579
|
continue
|
|
559
580
|
}
|
|
581
|
+
patternListStack.pop()
|
|
560
582
|
|
|
583
|
+
// closing an extglob
|
|
561
584
|
clearStateChar()
|
|
562
585
|
hasMagic = true
|
|
563
|
-
pl =
|
|
586
|
+
pl = plEntry
|
|
564
587
|
// negation is (?:(?!js)[^/]*)
|
|
565
588
|
// The others are (?:<pattern>)<type>
|
|
566
589
|
re += pl.close
|
|
567
590
|
if (pl.type === '!') {
|
|
568
|
-
negativeLists.push(pl)
|
|
591
|
+
negativeLists.push(Object.assign(pl, { reEnd: re.length }))
|
|
569
592
|
}
|
|
570
|
-
|
|
571
|
-
|
|
593
|
+
continue
|
|
594
|
+
}
|
|
572
595
|
|
|
573
|
-
case '|':
|
|
574
|
-
|
|
596
|
+
case '|': {
|
|
597
|
+
const plEntry = patternListStack[patternListStack.length - 1]
|
|
598
|
+
if (inClass || !plEntry) {
|
|
575
599
|
re += '\\|'
|
|
576
600
|
continue
|
|
577
601
|
}
|
|
578
602
|
|
|
579
603
|
clearStateChar()
|
|
580
604
|
re += '|'
|
|
581
|
-
|
|
605
|
+
// next subpattern can start with a dot?
|
|
606
|
+
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
607
|
+
dotTravAllowed = true
|
|
608
|
+
re += subPatternStart(pattern.slice(i + 1))
|
|
609
|
+
}
|
|
610
|
+
continue
|
|
611
|
+
}
|
|
582
612
|
|
|
583
613
|
// these are mostly the same in regexp and glob
|
|
584
614
|
case '[':
|
|
@@ -723,7 +753,8 @@ class Minimatch {
|
|
|
723
753
|
// Handle nested stuff like *(*.js|!(*.json)), where open parens
|
|
724
754
|
// mean that we should *not* include the ) in the bit that is considered
|
|
725
755
|
// "after" the negated section.
|
|
726
|
-
const
|
|
756
|
+
const closeParensBefore = nlBefore.split(')').length
|
|
757
|
+
const openParensBefore = nlBefore.split('(').length - closeParensBefore
|
|
727
758
|
let cleanAfter = nlAfter
|
|
728
759
|
for (let i = 0; i < openParensBefore; i++) {
|
|
729
760
|
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
|
|
@@ -742,7 +773,7 @@ class Minimatch {
|
|
|
742
773
|
}
|
|
743
774
|
|
|
744
775
|
if (addPatternStart) {
|
|
745
|
-
re = patternStart + re
|
|
776
|
+
re = patternStart() + re
|
|
746
777
|
}
|
|
747
778
|
|
|
748
779
|
// parsing just a piece of a larger pattern.
|
package/package.json
CHANGED
|
@@ -2,7 +2,10 @@
|
|
|
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": "4.2.
|
|
5
|
+
"version": "4.2.3",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"tag": "legacy-v4"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git://github.com/isaacs/minimatch.git"
|