Skip to content

Commit

Permalink
definitively set globParts, globSet in ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 16, 2023
1 parent 6c0c464 commit f2e6a21
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,16 +249,15 @@ export class Minimatch {
comment: boolean
empty: boolean
partial: boolean
globSet?: string[]
globParts?: string[][]
globSet: string[]
globParts: string[][]

regexp: false | null | MMRegExp
constructor(pattern: string, options: MinimatchOptions = {}) {
assertValidPattern(pattern)

options = options || {}
this.options = options
this.set = []
this.pattern = pattern
this.windowsPathsNoEscape =
!!options.windowsPathsNoEscape || options.allowWindowsEscape === false
Expand All @@ -272,6 +271,10 @@ export class Minimatch {
this.empty = false
this.partial = !!options.partial

this.globSet = []
this.globParts = []
this.set = []

// make the set of regexps etc.
this.make()
}
Expand All @@ -287,6 +290,7 @@ export class Minimatch {
this.comment = true
return
}

if (!pattern) {
this.empty = true
return
Expand All @@ -296,20 +300,20 @@ export class Minimatch {
this.parseNegate()

// step 2: expand braces
const globSet = (this.globSet = this.braceExpand())
this.globSet = this.braceExpand()

if (options.debug) {
this.debug = (...args: any[]) => console.error(...args)
}

this.debug(this.pattern, globSet)
this.debug(this.pattern, this.globSet)

// step 3: now we have a set, so turn each one into a series of path-portion
// matching patterns.
// These will be regexps, except in the case of "**", which is
// set to the GLOBSTAR object for globstar behavior,
// and will not contain any / characters
const rawGlobParts = globSet.map(s => s.split(slashSplit))
const rawGlobParts = this.globSet.map(s => s.split(slashSplit))

// consecutive globstars are an unncessary perf killer
this.globParts = this.options.noglobstar
Expand Down

0 comments on commit f2e6a21

Please sign in to comment.