react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / fileset / node_modules / glob / node_modules / minimatch / minimatch.js
80728 views;(function (require, exports, module, platform) {12if (module) module.exports = minimatch3else exports.minimatch = minimatch45if (!require) {6require = function (id) {7switch (id) {8case "sigmund": return function sigmund (obj) {9return JSON.stringify(obj)10}11case "path": return { basename: function (f) {12f = f.split(/[\/\\]/)13var e = f.pop()14if (!e) e = f.pop()15return e16}}17case "lru-cache": return function LRUCache () {18// not quite an LRU, but still space-limited.19var cache = {}20var cnt = 021this.set = function (k, v) {22cnt ++23if (cnt >= 100) cache = {}24cache[k] = v25}26this.get = function (k) { return cache[k] }27}28}29}30}3132minimatch.Minimatch = Minimatch3334var LRU = require("lru-cache")35, cache = minimatch.cache = new LRU({max: 100})36, GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}37, sigmund = require("sigmund")3839var path = require("path")40// any single thing other than /41// don't need to escape / when using new RegExp()42, qmark = "[^/]"4344// * => any number of characters45, star = qmark + "*?"4647// ** when dots are allowed. Anything goes, except .. and .48// not (^ or / followed by one or two dots followed by $ or /),49// followed by anything, any number of times.50, twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"5152// not a ^ or / followed by a dot,53// followed by anything, any number of times.54, twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"5556// characters that need to be escaped in RegExp.57, reSpecials = charSet("().*{}+?[]^$\\!")5859// "abc" -> { a:true, b:true, c:true }60function charSet (s) {61return s.split("").reduce(function (set, c) {62set[c] = true63return set64}, {})65}6667// normalizes slashes.68var slashSplit = /\/+/6970minimatch.filter = filter71function filter (pattern, options) {72options = options || {}73return function (p, i, list) {74return minimatch(p, pattern, options)75}76}7778function ext (a, b) {79a = a || {}80b = b || {}81var t = {}82Object.keys(b).forEach(function (k) {83t[k] = b[k]84})85Object.keys(a).forEach(function (k) {86t[k] = a[k]87})88return t89}9091minimatch.defaults = function (def) {92if (!def || !Object.keys(def).length) return minimatch9394var orig = minimatch9596var m = function minimatch (p, pattern, options) {97return orig.minimatch(p, pattern, ext(def, options))98}99100m.Minimatch = function Minimatch (pattern, options) {101return new orig.Minimatch(pattern, ext(def, options))102}103104return m105}106107Minimatch.defaults = function (def) {108if (!def || !Object.keys(def).length) return Minimatch109return minimatch.defaults(def).Minimatch110}111112113function minimatch (p, pattern, options) {114if (typeof pattern !== "string") {115throw new TypeError("glob pattern string required")116}117118if (!options) options = {}119120// shortcut: comments match nothing.121if (!options.nocomment && pattern.charAt(0) === "#") {122return false123}124125// "" only matches ""126if (pattern.trim() === "") return p === ""127128return new Minimatch(pattern, options).match(p)129}130131function Minimatch (pattern, options) {132if (!(this instanceof Minimatch)) {133return new Minimatch(pattern, options, cache)134}135136if (typeof pattern !== "string") {137throw new TypeError("glob pattern string required")138}139140if (!options) options = {}141pattern = pattern.trim()142143// windows: need to use /, not \144// On other platforms, \ is a valid (albeit bad) filename char.145if (platform === "win32") {146pattern = pattern.split("\\").join("/")147}148149// lru storage.150// these things aren't particularly big, but walking down the string151// and turning it into a regexp can get pretty costly.152var cacheKey = pattern + "\n" + sigmund(options)153var cached = minimatch.cache.get(cacheKey)154if (cached) return cached155minimatch.cache.set(cacheKey, this)156157this.options = options158this.set = []159this.pattern = pattern160this.regexp = null161this.negate = false162this.comment = false163this.empty = false164165// make the set of regexps etc.166this.make()167}168169Minimatch.prototype.debug = function() {}170171Minimatch.prototype.make = make172function make () {173// don't do it more than once.174if (this._made) return175176var pattern = this.pattern177var options = this.options178179// empty patterns and comments match nothing.180if (!options.nocomment && pattern.charAt(0) === "#") {181this.comment = true182return183}184if (!pattern) {185this.empty = true186return187}188189// step 1: figure out negation, etc.190this.parseNegate()191192// step 2: expand braces193var set = this.globSet = this.braceExpand()194195if (options.debug) this.debug = console.error196197this.debug(this.pattern, set)198199// step 3: now we have a set, so turn each one into a series of path-portion200// matching patterns.201// These will be regexps, except in the case of "**", which is202// set to the GLOBSTAR object for globstar behavior,203// and will not contain any / characters204set = this.globParts = set.map(function (s) {205return s.split(slashSplit)206})207208this.debug(this.pattern, set)209210// glob --> regexps211set = set.map(function (s, si, set) {212return s.map(this.parse, this)213}, this)214215this.debug(this.pattern, set)216217// filter out everything that didn't compile properly.218set = set.filter(function (s) {219return -1 === s.indexOf(false)220})221222this.debug(this.pattern, set)223224this.set = set225}226227Minimatch.prototype.parseNegate = parseNegate228function parseNegate () {229var pattern = this.pattern230, negate = false231, options = this.options232, negateOffset = 0233234if (options.nonegate) return235236for ( var i = 0, l = pattern.length237; i < l && pattern.charAt(i) === "!"238; i ++) {239negate = !negate240negateOffset ++241}242243if (negateOffset) this.pattern = pattern.substr(negateOffset)244this.negate = negate245}246247// Brace expansion:248// a{b,c}d -> abd acd249// a{b,}c -> abc ac250// a{0..3}d -> a0d a1d a2d a3d251// a{b,c{d,e}f}g -> abg acdfg acefg252// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg253//254// Invalid sets are not expanded.255// a{2..}b -> a{2..}b256// a{b}c -> a{b}c257minimatch.braceExpand = function (pattern, options) {258return new Minimatch(pattern, options).braceExpand()259}260261Minimatch.prototype.braceExpand = braceExpand262function braceExpand (pattern, options) {263options = options || this.options264pattern = typeof pattern === "undefined"265? this.pattern : pattern266267if (typeof pattern === "undefined") {268throw new Error("undefined pattern")269}270271if (options.nobrace ||272!pattern.match(/\{.*\}/)) {273// shortcut. no need to expand.274return [pattern]275}276277var escaping = false278279// examples and comments refer to this crazy pattern:280// a{b,c{d,e},{f,g}h}x{y,z}281// expected:282// abxy283// abxz284// acdxy285// acdxz286// acexy287// acexz288// afhxy289// afhxz290// aghxy291// aghxz292293// everything before the first \{ is just a prefix.294// So, we pluck that off, and work with the rest,295// and then prepend it to everything we find.296if (pattern.charAt(0) !== "{") {297this.debug(pattern)298var prefix = null299for (var i = 0, l = pattern.length; i < l; i ++) {300var c = pattern.charAt(i)301this.debug(i, c)302if (c === "\\") {303escaping = !escaping304} else if (c === "{" && !escaping) {305prefix = pattern.substr(0, i)306break307}308}309310// actually no sets, all { were escaped.311if (prefix === null) {312this.debug("no sets")313return [pattern]314}315316var tail = braceExpand.call(this, pattern.substr(i), options)317return tail.map(function (t) {318return prefix + t319})320}321322// now we have something like:323// {b,c{d,e},{f,g}h}x{y,z}324// walk through the set, expanding each part, until325// the set ends. then, we'll expand the suffix.326// If the set only has a single member, then'll put the {} back327328// first, handle numeric sets, since they're easier329var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/)330if (numset) {331this.debug("numset", numset[1], numset[2])332var suf = braceExpand.call(this, pattern.substr(numset[0].length), options)333, start = +numset[1]334, end = +numset[2]335, inc = start > end ? -1 : 1336, set = []337for (var i = start; i != (end + inc); i += inc) {338// append all the suffixes339for (var ii = 0, ll = suf.length; ii < ll; ii ++) {340set.push(i + suf[ii])341}342}343return set344}345346// ok, walk through the set347// We hope, somewhat optimistically, that there348// will be a } at the end.349// If the closing brace isn't found, then the pattern is350// interpreted as braceExpand("\\" + pattern) so that351// the leading \{ will be interpreted literally.352var i = 1 // skip the \{353, depth = 1354, set = []355, member = ""356, sawEnd = false357, escaping = false358359function addMember () {360set.push(member)361member = ""362}363364this.debug("Entering for")365FOR: for (i = 1, l = pattern.length; i < l; i ++) {366var c = pattern.charAt(i)367this.debug("", i, c)368369if (escaping) {370escaping = false371member += "\\" + c372} else {373switch (c) {374case "\\":375escaping = true376continue377378case "{":379depth ++380member += "{"381continue382383case "}":384depth --385// if this closes the actual set, then we're done386if (depth === 0) {387addMember()388// pluck off the close-brace389i ++390break FOR391} else {392member += c393continue394}395396case ",":397if (depth === 1) {398addMember()399} else {400member += c401}402continue403404default:405member += c406continue407} // switch408} // else409} // for410411// now we've either finished the set, and the suffix is412// pattern.substr(i), or we have *not* closed the set,413// and need to escape the leading brace414if (depth !== 0) {415this.debug("didn't close", pattern)416return braceExpand.call(this, "\\" + pattern, options)417}418419// x{y,z} -> ["xy", "xz"]420this.debug("set", set)421this.debug("suffix", pattern.substr(i))422var suf = braceExpand.call(this, pattern.substr(i), options)423// ["b", "c{d,e}","{f,g}h"] ->424// [["b"], ["cd", "ce"], ["fh", "gh"]]425var addBraces = set.length === 1426this.debug("set pre-expanded", set)427set = set.map(function (p) {428return braceExpand.call(this, p, options)429}, this)430this.debug("set expanded", set)431432433// [["b"], ["cd", "ce"], ["fh", "gh"]] ->434// ["b", "cd", "ce", "fh", "gh"]435set = set.reduce(function (l, r) {436return l.concat(r)437})438439if (addBraces) {440set = set.map(function (s) {441return "{" + s + "}"442})443}444445// now attach the suffixes.446var ret = []447for (var i = 0, l = set.length; i < l; i ++) {448for (var ii = 0, ll = suf.length; ii < ll; ii ++) {449ret.push(set[i] + suf[ii])450}451}452return ret453}454455// parse a component of the expanded set.456// At this point, no pattern may contain "/" in it457// so we're going to return a 2d array, where each entry is the full458// pattern, split on '/', and then turned into a regular expression.459// A regexp is made at the end which joins each array with an460// escaped /, and another full one which joins each regexp with |.461//462// Following the lead of Bash 4.1, note that "**" only has special meaning463// when it is the *only* thing in a path portion. Otherwise, any series464// of * is equivalent to a single *. Globstar behavior is enabled by465// default, and can be disabled by setting options.noglobstar.466Minimatch.prototype.parse = parse467var SUBPARSE = {}468function parse (pattern, isSub) {469var options = this.options470471// shortcuts472if (!options.noglobstar && pattern === "**") return GLOBSTAR473if (pattern === "") return ""474475var re = ""476, hasMagic = !!options.nocase477, escaping = false478// ? => one single character479, patternListStack = []480, plType481, stateChar482, inClass = false483, reClassStart = -1484, classStart = -1485// . and .. never match anything that doesn't start with .,486// even when options.dot is set.487, patternStart = pattern.charAt(0) === "." ? "" // anything488// not (start or / followed by . or .. followed by / or end)489: options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"490: "(?!\\.)"491, self = this492493function clearStateChar () {494if (stateChar) {495// we had some state-tracking character496// that wasn't consumed by this pass.497switch (stateChar) {498case "*":499re += star500hasMagic = true501break502case "?":503re += qmark504hasMagic = true505break506default:507re += "\\"+stateChar508break509}510self.debug('clearStateChar %j %j', stateChar, re)511stateChar = false512}513}514515for ( var i = 0, len = pattern.length, c516; (i < len) && (c = pattern.charAt(i))517; i ++ ) {518519this.debug("%s\t%s %s %j", pattern, i, re, c)520521// skip over any that are escaped.522if (escaping && reSpecials[c]) {523re += "\\" + c524escaping = false525continue526}527528SWITCH: switch (c) {529case "/":530// completely not allowed, even escaped.531// Should already be path-split by now.532return false533534case "\\":535clearStateChar()536escaping = true537continue538539// the various stateChar values540// for the "extglob" stuff.541case "?":542case "*":543case "+":544case "@":545case "!":546this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)547548// all of those are literals inside a class, except that549// the glob [!a] means [^a] in regexp550if (inClass) {551this.debug(' in class')552if (c === "!" && i === classStart + 1) c = "^"553re += c554continue555}556557// if we already have a stateChar, then it means558// that there was something like ** or +? in there.559// Handle the stateChar, then proceed with this one.560self.debug('call clearStateChar %j', stateChar)561clearStateChar()562stateChar = c563// if extglob is disabled, then +(asdf|foo) isn't a thing.564// just clear the statechar *now*, rather than even diving into565// the patternList stuff.566if (options.noext) clearStateChar()567continue568569case "(":570if (inClass) {571re += "("572continue573}574575if (!stateChar) {576re += "\\("577continue578}579580plType = stateChar581patternListStack.push({ type: plType582, start: i - 1583, reStart: re.length })584// negation is (?:(?!js)[^/]*)585re += stateChar === "!" ? "(?:(?!" : "(?:"586this.debug('plType %j %j', stateChar, re)587stateChar = false588continue589590case ")":591if (inClass || !patternListStack.length) {592re += "\\)"593continue594}595596clearStateChar()597hasMagic = true598re += ")"599plType = patternListStack.pop().type600// negation is (?:(?!js)[^/]*)601// The others are (?:<pattern>)<type>602switch (plType) {603case "!":604re += "[^/]*?)"605break606case "?":607case "+":608case "*": re += plType609case "@": break // the default anyway610}611continue612613case "|":614if (inClass || !patternListStack.length || escaping) {615re += "\\|"616escaping = false617continue618}619620clearStateChar()621re += "|"622continue623624// these are mostly the same in regexp and glob625case "[":626// swallow any state-tracking char before the [627clearStateChar()628629if (inClass) {630re += "\\" + c631continue632}633634inClass = true635classStart = i636reClassStart = re.length637re += c638continue639640case "]":641// a right bracket shall lose its special642// meaning and represent itself in643// a bracket expression if it occurs644// first in the list. -- POSIX.2 2.8.3.2645if (i === classStart + 1 || !inClass) {646re += "\\" + c647escaping = false648continue649}650651// finish up the class.652hasMagic = true653inClass = false654re += c655continue656657default:658// swallow any state char that wasn't consumed659clearStateChar()660661if (escaping) {662// no need663escaping = false664} else if (reSpecials[c]665&& !(c === "^" && inClass)) {666re += "\\"667}668669re += c670671} // switch672} // for673674675// handle the case where we left a class open.676// "[abc" is valid, equivalent to "\[abc"677if (inClass) {678// split where the last [ was, and escape it679// this is a huge pita. We now have to re-walk680// the contents of the would-be class to re-translate681// any characters that were passed through as-is682var cs = pattern.substr(classStart + 1)683, sp = this.parse(cs, SUBPARSE)684re = re.substr(0, reClassStart) + "\\[" + sp[0]685hasMagic = hasMagic || sp[1]686}687688// handle the case where we had a +( thing at the *end*689// of the pattern.690// each pattern list stack adds 3 chars, and we need to go through691// and escape any | chars that were passed through as-is for the regexp.692// Go through and escape them, taking care not to double-escape any693// | chars that were already escaped.694var pl695while (pl = patternListStack.pop()) {696var tail = re.slice(pl.reStart + 3)697// maybe some even number of \, then maybe 1 \, followed by a |698tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {699if (!$2) {700// the | isn't already escaped, so escape it.701$2 = "\\"702}703704// need to escape all those slashes *again*, without escaping the705// one that we need for escaping the | character. As it works out,706// escaping an even number of slashes can be done by simply repeating707// it exactly after itself. That's why this trick works.708//709// I am sorry that you have to see this.710return $1 + $1 + $2 + "|"711})712713this.debug("tail=%j\n %s", tail, tail)714var t = pl.type === "*" ? star715: pl.type === "?" ? qmark716: "\\" + pl.type717718hasMagic = true719re = re.slice(0, pl.reStart)720+ t + "\\("721+ tail722}723724// handle trailing things that only matter at the very end.725clearStateChar()726if (escaping) {727// trailing \\728re += "\\\\"729}730731// only need to apply the nodot start if the re starts with732// something that could conceivably capture a dot733var addPatternStart = false734switch (re.charAt(0)) {735case ".":736case "[":737case "(": addPatternStart = true738}739740// if the re is not "" at this point, then we need to make sure741// it doesn't match against an empty path part.742// Otherwise a/* will match a/, which it should not.743if (re !== "" && hasMagic) re = "(?=.)" + re744745if (addPatternStart) re = patternStart + re746747// parsing just a piece of a larger pattern.748if (isSub === SUBPARSE) {749return [ re, hasMagic ]750}751752// skip the regexp for non-magical patterns753// unescape anything in it, though, so that it'll be754// an exact match against a file etc.755if (!hasMagic) {756return globUnescape(pattern)757}758759var flags = options.nocase ? "i" : ""760, regExp = new RegExp("^" + re + "$", flags)761762regExp._glob = pattern763regExp._src = re764765return regExp766}767768minimatch.makeRe = function (pattern, options) {769return new Minimatch(pattern, options || {}).makeRe()770}771772Minimatch.prototype.makeRe = makeRe773function makeRe () {774if (this.regexp || this.regexp === false) return this.regexp775776// at this point, this.set is a 2d array of partial777// pattern strings, or "**".778//779// It's better to use .match(). This function shouldn't780// be used, really, but it's pretty convenient sometimes,781// when you just want to work with a regex.782var set = this.set783784if (!set.length) return this.regexp = false785var options = this.options786787var twoStar = options.noglobstar ? star788: options.dot ? twoStarDot789: twoStarNoDot790, flags = options.nocase ? "i" : ""791792var re = set.map(function (pattern) {793return pattern.map(function (p) {794return (p === GLOBSTAR) ? twoStar795: (typeof p === "string") ? regExpEscape(p)796: p._src797}).join("\\\/")798}).join("|")799800// must match entire pattern801// ending in a * or ** will make it less strict.802re = "^(?:" + re + ")$"803804// can match anything, as long as it's not this.805if (this.negate) re = "^(?!" + re + ").*$"806807try {808return this.regexp = new RegExp(re, flags)809} catch (ex) {810return this.regexp = false811}812}813814minimatch.match = function (list, pattern, options) {815options = options || {}816var mm = new Minimatch(pattern, options)817list = list.filter(function (f) {818return mm.match(f)819})820if (mm.options.nonull && !list.length) {821list.push(pattern)822}823return list824}825826Minimatch.prototype.match = match827function match (f, partial) {828this.debug("match", f, this.pattern)829// short-circuit in the case of busted things.830// comments, etc.831if (this.comment) return false832if (this.empty) return f === ""833834if (f === "/" && partial) return true835836var options = this.options837838// windows: need to use /, not \839// On other platforms, \ is a valid (albeit bad) filename char.840if (platform === "win32") {841f = f.split("\\").join("/")842}843844// treat the test path as a set of pathparts.845f = f.split(slashSplit)846this.debug(this.pattern, "split", f)847848// just ONE of the pattern sets in this.set needs to match849// in order for it to be valid. If negating, then just one850// match means that we have failed.851// Either way, return on the first hit.852853var set = this.set854this.debug(this.pattern, "set", set)855856// Find the basename of the path by looking for the last non-empty segment857var filename;858for (var i = f.length - 1; i >= 0; i--) {859filename = f[i]860if (filename) break861}862863for (var i = 0, l = set.length; i < l; i ++) {864var pattern = set[i], file = f865if (options.matchBase && pattern.length === 1) {866file = [filename]867}868var hit = this.matchOne(file, pattern, partial)869if (hit) {870if (options.flipNegate) return true871return !this.negate872}873}874875// didn't get any hits. this is success if it's a negative876// pattern, failure otherwise.877if (options.flipNegate) return false878return this.negate879}880881// set partial to true to test if, for example,882// "/a/b" matches the start of "/*/b/*/d"883// Partial means, if you run out of file before you run884// out of pattern, then that's fine, as long as all885// the parts match.886Minimatch.prototype.matchOne = function (file, pattern, partial) {887var options = this.options888889this.debug("matchOne",890{ "this": this891, file: file892, pattern: pattern })893894this.debug("matchOne", file.length, pattern.length)895896for ( var fi = 0897, pi = 0898, fl = file.length899, pl = pattern.length900; (fi < fl) && (pi < pl)901; fi ++, pi ++ ) {902903this.debug("matchOne loop")904var p = pattern[pi]905, f = file[fi]906907this.debug(pattern, p, f)908909// should be impossible.910// some invalid regexp stuff in the set.911if (p === false) return false912913if (p === GLOBSTAR) {914this.debug('GLOBSTAR', [pattern, p, f])915916// "**"917// a/**/b/**/c would match the following:918// a/b/x/y/z/c919// a/x/y/z/b/c920// a/b/x/b/x/c921// a/b/c922// To do this, take the rest of the pattern after923// the **, and see if it would match the file remainder.924// If so, return success.925// If not, the ** "swallows" a segment, and try again.926// This is recursively awful.927//928// a/**/b/**/c matching a/b/x/y/z/c929// - a matches a930// - doublestar931// - matchOne(b/x/y/z/c, b/**/c)932// - b matches b933// - doublestar934// - matchOne(x/y/z/c, c) -> no935// - matchOne(y/z/c, c) -> no936// - matchOne(z/c, c) -> no937// - matchOne(c, c) yes, hit938var fr = fi939, pr = pi + 1940if (pr === pl) {941this.debug('** at the end')942// a ** at the end will just swallow the rest.943// We have found a match.944// however, it will not swallow /.x, unless945// options.dot is set.946// . and .. are *never* matched by **, for explosively947// exponential reasons.948for ( ; fi < fl; fi ++) {949if (file[fi] === "." || file[fi] === ".." ||950(!options.dot && file[fi].charAt(0) === ".")) return false951}952return true953}954955// ok, let's see if we can swallow whatever we can.956WHILE: while (fr < fl) {957var swallowee = file[fr]958959this.debug('\nglobstar while',960file, fr, pattern, pr, swallowee)961962// XXX remove this slice. Just pass the start index.963if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {964this.debug('globstar found match!', fr, fl, swallowee)965// found a match.966return true967} else {968// can't swallow "." or ".." ever.969// can only swallow ".foo" when explicitly asked.970if (swallowee === "." || swallowee === ".." ||971(!options.dot && swallowee.charAt(0) === ".")) {972this.debug("dot detected!", file, fr, pattern, pr)973break WHILE974}975976// ** swallows a segment, and continue.977this.debug('globstar swallow a segment, and continue')978fr ++979}980}981// no match was found.982// However, in partial mode, we can't say this is necessarily over.983// If there's more *pattern* left, then984if (partial) {985// ran out of file986this.debug("\n>>> no match, partial?", file, fr, pattern, pr)987if (fr === fl) return true988}989return false990}991992// something other than **993// non-magic patterns just have to match exactly994// patterns with magic have been turned into regexps.995var hit996if (typeof p === "string") {997if (options.nocase) {998hit = f.toLowerCase() === p.toLowerCase()999} else {1000hit = f === p1001}1002this.debug("string match", p, f, hit)1003} else {1004hit = f.match(p)1005this.debug("pattern match", p, f, hit)1006}10071008if (!hit) return false1009}10101011// Note: ending in / means that we'll get a final ""1012// at the end of the pattern. This can only match a1013// corresponding "" at the end of the file.1014// If the file ends in /, then it can only match a1015// a pattern that ends in /, unless the pattern just1016// doesn't have any more for it. But, a/b/ should *not*1017// match "a/b/*", even though "" matches against the1018// [^/]*? pattern, except in partial mode, where it might1019// simply not be reached yet.1020// However, a/b/ should still satisfy a/*10211022// now either we fell off the end of the pattern, or we're done.1023if (fi === fl && pi === pl) {1024// ran out of pattern and filename at the same time.1025// an exact hit!1026return true1027} else if (fi === fl) {1028// ran out of file, but still had pattern left.1029// this is ok if we're doing the match as part of1030// a glob fs traversal.1031return partial1032} else if (pi === pl) {1033// ran out of pattern, still have file left.1034// this is only acceptable if we're on the very last1035// empty segment of a file with a trailing slash.1036// a/* should match a/b/1037var emptyFileEnd = (fi === fl - 1) && (file[fi] === "")1038return emptyFileEnd1039}10401041// should be unreachable.1042throw new Error("wtf?")1043}104410451046// replace stuff like \* with *1047function globUnescape (s) {1048return s.replace(/\\(.)/g, "$1")1049}105010511052function regExpEscape (s) {1053return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")1054}10551056})( typeof require === "function" ? require : null,1057this,1058typeof module === "object" ? module : null,1059typeof process === "object" ? process.platform : "win32"1060)106110621063