minimatch 5.1.4 → 5.1.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.
- 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) {
|
|
@@ -533,7 +545,7 @@ class Minimatch {
|
|
|
533
545
|
if (options.noext) clearStateChar()
|
|
534
546
|
continue
|
|
535
547
|
|
|
536
|
-
case '(':
|
|
548
|
+
case '(': {
|
|
537
549
|
if (inClass) {
|
|
538
550
|
re += '('
|
|
539
551
|
continue
|
|
@@ -544,46 +556,64 @@ class Minimatch {
|
|
|
544
556
|
continue
|
|
545
557
|
}
|
|
546
558
|
|
|
547
|
-
|
|
559
|
+
const plEntry = {
|
|
548
560
|
type: stateChar,
|
|
549
561
|
start: i - 1,
|
|
550
562
|
reStart: re.length,
|
|
551
563
|
open: plTypes[stateChar].open,
|
|
552
|
-
close: plTypes[stateChar].close
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
|
|
564
|
+
close: plTypes[stateChar].close,
|
|
565
|
+
}
|
|
566
|
+
this.debug(this.pattern, '\t', plEntry)
|
|
567
|
+
patternListStack.push(plEntry)
|
|
568
|
+
// negation is (?:(?!(?:js)(?:<rest>))[^/]*)
|
|
569
|
+
re += plEntry.open
|
|
570
|
+
// next entry starts with a dot maybe?
|
|
571
|
+
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
572
|
+
dotTravAllowed = true
|
|
573
|
+
re += subPatternStart(pattern.slice(i + 1))
|
|
574
|
+
}
|
|
556
575
|
this.debug('plType %j %j', stateChar, re)
|
|
557
576
|
stateChar = false
|
|
558
|
-
|
|
577
|
+
continue
|
|
578
|
+
}
|
|
559
579
|
|
|
560
|
-
case ')':
|
|
561
|
-
|
|
580
|
+
case ')': {
|
|
581
|
+
const plEntry = patternListStack[patternListStack.length - 1]
|
|
582
|
+
if (inClass || !plEntry) {
|
|
562
583
|
re += '\\)'
|
|
563
584
|
continue
|
|
564
585
|
}
|
|
586
|
+
patternListStack.pop()
|
|
565
587
|
|
|
588
|
+
// closing an extglob
|
|
566
589
|
clearStateChar()
|
|
567
590
|
hasMagic = true
|
|
568
|
-
pl =
|
|
591
|
+
pl = plEntry
|
|
569
592
|
// negation is (?:(?!js)[^/]*)
|
|
570
593
|
// The others are (?:<pattern>)<type>
|
|
571
594
|
re += pl.close
|
|
572
595
|
if (pl.type === '!') {
|
|
573
|
-
negativeLists.push(pl)
|
|
596
|
+
negativeLists.push(Object.assign(pl, { reEnd: re.length }))
|
|
574
597
|
}
|
|
575
|
-
|
|
576
|
-
|
|
598
|
+
continue
|
|
599
|
+
}
|
|
577
600
|
|
|
578
|
-
case '|':
|
|
579
|
-
|
|
601
|
+
case '|': {
|
|
602
|
+
const plEntry = patternListStack[patternListStack.length - 1]
|
|
603
|
+
if (inClass || !plEntry) {
|
|
580
604
|
re += '\\|'
|
|
581
605
|
continue
|
|
582
606
|
}
|
|
583
607
|
|
|
584
608
|
clearStateChar()
|
|
585
609
|
re += '|'
|
|
586
|
-
|
|
610
|
+
// next subpattern can start with a dot?
|
|
611
|
+
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
612
|
+
dotTravAllowed = true
|
|
613
|
+
re += subPatternStart(pattern.slice(i + 1))
|
|
614
|
+
}
|
|
615
|
+
continue
|
|
616
|
+
}
|
|
587
617
|
|
|
588
618
|
// these are mostly the same in regexp and glob
|
|
589
619
|
case '[':
|
|
@@ -722,7 +752,8 @@ class Minimatch {
|
|
|
722
752
|
// Handle nested stuff like *(*.js|!(*.json)), where open parens
|
|
723
753
|
// mean that we should *not* include the ) in the bit that is considered
|
|
724
754
|
// "after" the negated section.
|
|
725
|
-
const
|
|
755
|
+
const closeParensBefore = nlBefore.split(')').length
|
|
756
|
+
const openParensBefore = nlBefore.split('(').length - closeParensBefore
|
|
726
757
|
let cleanAfter = nlAfter
|
|
727
758
|
for (let i = 0; i < openParensBefore; i++) {
|
|
728
759
|
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
|
-
"
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"tag": "legacy-v5"
|
|
7
|
+
},
|
|
8
|
+
"version": "5.1.6",
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "git://github.com/isaacs/minimatch.git"
|