Lines Matching full:pattern
1 const minimatch = module.exports = (p, pattern, options = {}) => {
2 assertValidPattern(pattern)
5 if (!options.nocomment && pattern.charAt(0) === '#') {
9 return new Minimatch(pattern, options).match(p)
54 // characters that indicate we have to add the pattern start
60 minimatch.filter = (pattern, options = {}) => argument
61 (p, i, list) => minimatch(p, pattern, options)
77 const m = (p, pattern, options) => orig(p, pattern, ext(def, options)) argument
79 constructor (pattern, options) { argument
80 super(pattern, ext(def, options))
84 m.filter = (pattern, options) => orig.filter(pattern, ext(def, options)) argument
86 m.makeRe = (pattern, options) => orig.makeRe(pattern, ext(def, options)) argument
87 m.braceExpand = (pattern, options) => orig.braceExpand(pattern, ext(def, options)) argument
88 m.match = (list, pattern, options) => orig.match(list, pattern, ext(def, options)) argument
107 minimatch.braceExpand = (pattern, options) => braceExpand(pattern, options) argument
109 const braceExpand = (pattern, options = {}) => { argument
110 assertValidPattern(pattern)
114 if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
116 return [pattern]
119 return expand(pattern)
123 const assertValidPattern = pattern => { argument
124 if (typeof pattern !== 'string') {
125 throw new TypeError('invalid pattern')
128 if (pattern.length > MAX_PATTERN_LENGTH) {
129 throw new TypeError('pattern is too long')
134 // At this point, no pattern may contain "/" in it
136 // pattern, split on '/', and then turned into a regular expression.
146 minimatch.makeRe = (pattern, options) => argument
147 new Minimatch(pattern, options || {}).makeRe()
149 minimatch.match = (list, pattern, options = {}) => { argument
150 const mm = new Minimatch(pattern, options)
153 list.push(pattern)
165 constructor (pattern, options) { argument
166 assertValidPattern(pattern)
172 this.pattern = pattern
176 this.pattern = this.pattern.replace(/\\/g, '/')
191 const pattern = this.pattern
195 if (!options.nocomment && pattern.charAt(0) === '#') {
199 if (!pattern) {
212 this.debug(this.pattern, set)
221 this.debug(this.pattern, set)
226 this.debug(this.pattern, set)
231 this.debug(this.pattern, set)
239 const pattern = this.pattern
243 for (let i = 0; i < pattern.length && pattern.charAt(i) === '!'; i++) {
248 if (negateOffset) this.pattern = pattern.slice(negateOffset)
255 // out of pattern, then that's fine, as long as all
257 matchOne (file, pattern, partial) { argument
261 { 'this': this, file: file, pattern: pattern }) property
263 this.debug('matchOne', file.length, pattern.length)
268 pl = pattern.length
272 var p = pattern[pi]
275 this.debug(pattern, p, f)
283 this.debug('GLOBSTAR', [pattern, p, f])
291 // To do this, take the rest of the pattern after
328 this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
331 if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
340 this.debug('dot detected!', file, fr, pattern, pr)
352 // If there's more *pattern* left, then
356 this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
371 this.debug('pattern match', p, f, hit)
378 // at the end of the pattern. This can only match a
381 // a pattern that ends in /, unless the pattern just
384 // [^/]*? pattern, except in partial mode, where it might
388 // now either we fell off the end of the pattern, or we're done.
390 // ran out of pattern and filename at the same time.
394 // ran out of file, but still had pattern left.
399 // ran out of pattern, still have file left.
412 return braceExpand(this.pattern, this.options)
415 parse (pattern, isSub) { argument
416 assertValidPattern(pattern)
421 if (pattern === '**') {
425 pattern = '*'
427 if (pattern === '') return ''
443 // even when options.dot is set. However, if the pattern
445 let dotTravAllowed = pattern.charAt(0) === '.'
483 for (let i = 0, c; (i < pattern.length) && (c = pattern.charAt(i)); i++) {
484 this.debug('%s\t%s %s %j', pattern, i, re, c)
509 if (inClass && pattern.charAt(i + 1) === '-') {
525 this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
566 this.debug(this.pattern, '\t', plEntry)
573 re += subPatternStart(pattern.slice(i + 1))
593 // The others are (?:<pattern>)<type>
613 re += subPatternStart(pattern.slice(i + 1))
651 cs = pattern.substring(classStart + 1, i)
686 cs = pattern.slice(classStart + 1)
693 // of the pattern.
694 // each pattern list stack adds 3 chars, and we need to go through
740 // A pattern like: *.!(x).!(y|z) needs to ensure that a name
743 // the pattern.
779 // parsing just a piece of a larger pattern.
786 hasMagic = pattern.toUpperCase() !== pattern.toLowerCase()
793 return globUnescape(pattern)
799 _glob: pattern,
815 // pattern strings, or "**".
839 let re = set.map(pattern => {
840 pattern = pattern.map(p =>
850 pattern.forEach((p, i) => {
851 if (p !== GLOBSTAR || pattern[i-1] === GLOBSTAR) {
855 if (pattern.length > 1) {
856 pattern[i+1] = '(?:\\\/|' + twoStar + '\\\/)?' + pattern[i+1]
858 pattern[i] = twoStar
860 } else if (i === pattern.length - 1) {
861 pattern[i-1] += '(?:\\\/|' + twoStar + ')?'
863 pattern[i-1] += '(?:\\\/|\\\/' + twoStar + '\\\/)' + pattern[i+1]
864 pattern[i+1] = GLOBSTAR
867 return pattern.filter(p => p !== GLOBSTAR).join('/')
870 // must match entire pattern
886 this.debug('match', f, this.pattern)
903 this.debug(this.pattern, 'split', f)
905 // just ONE of the pattern sets in this.set needs to match
911 this.debug(this.pattern, 'set', set)
921 const pattern = set[i]
923 if (options.matchBase && pattern.length === 1) {
926 const hit = this.matchOne(file, pattern, partial)
934 // pattern, failure otherwise.