react / wstein / node_modules / jest-cli / node_modules / istanbul / node_modules / fileset / node_modules / minimatch / minimatch.js
80711 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 = braceExpand262263function pad(n, width, z) {264z = z || '0';265n = n + '';266return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;267}268269function braceExpand (pattern, options) {270options = options || this.options271pattern = typeof pattern === "undefined"272? this.pattern : pattern273274if (typeof pattern === "undefined") {275throw new Error("undefined pattern")276}277278if (options.nobrace ||279!pattern.match(/\{.*\}/)) {280// shortcut. no need to expand.281return [pattern]282}283284var escaping = false285286// examples and comments refer to this crazy pattern:287// a{b,c{d,e},{f,g}h}x{y,z}288// expected:289// abxy290// abxz291// acdxy292// acdxz293// acexy294// acexz295// afhxy296// afhxz297// aghxy298// aghxz299300// everything before the first \{ is just a prefix.301// So, we pluck that off, and work with the rest,302// and then prepend it to everything we find.303if (pattern.charAt(0) !== "{") {304this.debug(pattern)305var prefix = null306for (var i = 0, l = pattern.length; i < l; i ++) {307var c = pattern.charAt(i)308this.debug(i, c)309if (c === "\\") {310escaping = !escaping311} else if (c === "{" && !escaping) {312prefix = pattern.substr(0, i)313break314}315}316317// actually no sets, all { were escaped.318if (prefix === null) {319this.debug("no sets")320return [pattern]321}322323var tail = braceExpand.call(this, pattern.substr(i), options)324return tail.map(function (t) {325return prefix + t326})327}328329// now we have something like:330// {b,c{d,e},{f,g}h}x{y,z}331// walk through the set, expanding each part, until332// the set ends. then, we'll expand the suffix.333// If the set only has a single member, then'll put the {} back334335// first, handle numeric sets, since they're easier336var numset = pattern.match(/^\{(-?[0-9]+)\.\.(-?[0-9]+)\}/)337if (numset) {338this.debug("numset", numset[1], numset[2])339var suf = braceExpand.call(this, pattern.substr(numset[0].length), options)340, start = +numset[1]341, needPadding = numset[1][0] === '0'342, startWidth = numset[1].length343, padded344, end = +numset[2]345, inc = start > end ? -1 : 1346, set = []347348for (var i = start; i != (end + inc); i += inc) {349padded = needPadding ? pad(i, startWidth) : i + ''350// append all the suffixes351for (var ii = 0, ll = suf.length; ii < ll; ii ++) {352set.push(padded + suf[ii])353}354}355return set356}357358// ok, walk through the set359// We hope, somewhat optimistically, that there360// will be a } at the end.361// If the closing brace isn't found, then the pattern is362// interpreted as braceExpand("\\" + pattern) so that363// the leading \{ will be interpreted literally.364var i = 1 // skip the \{365, depth = 1366, set = []367, member = ""368, sawEnd = false369, escaping = false370371function addMember () {372set.push(member)373member = ""374}375376this.debug("Entering for")377FOR: for (i = 1, l = pattern.length; i < l; i ++) {378var c = pattern.charAt(i)379this.debug("", i, c)380381if (escaping) {382escaping = false383member += "\\" + c384} else {385switch (c) {386case "\\":387escaping = true388continue389390case "{":391depth ++392member += "{"393continue394395case "}":396depth --397// if this closes the actual set, then we're done398if (depth === 0) {399addMember()400// pluck off the close-brace401i ++402break FOR403} else {404member += c405continue406}407408case ",":409if (depth === 1) {410addMember()411} else {412member += c413}414continue415416default:417member += c418continue419} // switch420} // else421} // for422423// now we've either finished the set, and the suffix is424// pattern.substr(i), or we have *not* closed the set,425// and need to escape the leading brace426if (depth !== 0) {427this.debug("didn't close", pattern)428return braceExpand.call(this, "\\" + pattern, options)429}430431// x{y,z} -> ["xy", "xz"]432this.debug("set", set)433this.debug("suffix", pattern.substr(i))434var suf = braceExpand.call(this, pattern.substr(i), options)435// ["b", "c{d,e}","{f,g}h"] ->436// [["b"], ["cd", "ce"], ["fh", "gh"]]437var addBraces = set.length === 1438this.debug("set pre-expanded", set)439set = set.map(function (p) {440return braceExpand.call(this, p, options)441}, this)442this.debug("set expanded", set)443444445// [["b"], ["cd", "ce"], ["fh", "gh"]] ->446// ["b", "cd", "ce", "fh", "gh"]447set = set.reduce(function (l, r) {448return l.concat(r)449})450451if (addBraces) {452set = set.map(function (s) {453return "{" + s + "}"454})455}456457// now attach the suffixes.458var ret = []459for (var i = 0, l = set.length; i < l; i ++) {460for (var ii = 0, ll = suf.length; ii < ll; ii ++) {461ret.push(set[i] + suf[ii])462}463}464return ret465}466467// parse a component of the expanded set.468// At this point, no pattern may contain "/" in it469// so we're going to return a 2d array, where each entry is the full470// pattern, split on '/', and then turned into a regular expression.471// A regexp is made at the end which joins each array with an472// escaped /, and another full one which joins each regexp with |.473//474// Following the lead of Bash 4.1, note that "**" only has special meaning475// when it is the *only* thing in a path portion. Otherwise, any series476// of * is equivalent to a single *. Globstar behavior is enabled by477// default, and can be disabled by setting options.noglobstar.478Minimatch.prototype.parse = parse479var SUBPARSE = {}480function parse (pattern, isSub) {481var options = this.options482483// shortcuts484if (!options.noglobstar && pattern === "**") return GLOBSTAR485if (pattern === "") return ""486487var re = ""488, hasMagic = !!options.nocase489, escaping = false490// ? => one single character491, patternListStack = []492, plType493, stateChar494, inClass = false495, reClassStart = -1496, classStart = -1497// . and .. never match anything that doesn't start with .,498// even when options.dot is set.499, patternStart = pattern.charAt(0) === "." ? "" // anything500// not (start or / followed by . or .. followed by / or end)501: options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"502: "(?!\\.)"503, self = this504505function clearStateChar () {506if (stateChar) {507// we had some state-tracking character508// that wasn't consumed by this pass.509switch (stateChar) {510case "*":511re += star512hasMagic = true513break514case "?":515re += qmark516hasMagic = true517break518default:519re += "\\"+stateChar520break521}522self.debug('clearStateChar %j %j', stateChar, re)523stateChar = false524}525}526527for ( var i = 0, len = pattern.length, c528; (i < len) && (c = pattern.charAt(i))529; i ++ ) {530531this.debug("%s\t%s %s %j", pattern, i, re, c)532533// skip over any that are escaped.534if (escaping && reSpecials[c]) {535re += "\\" + c536escaping = false537continue538}539540SWITCH: switch (c) {541case "/":542// completely not allowed, even escaped.543// Should already be path-split by now.544return false545546case "\\":547clearStateChar()548escaping = true549continue550551// the various stateChar values552// for the "extglob" stuff.553case "?":554case "*":555case "+":556case "@":557case "!":558this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)559560// all of those are literals inside a class, except that561// the glob [!a] means [^a] in regexp562if (inClass) {563this.debug(' in class')564if (c === "!" && i === classStart + 1) c = "^"565re += c566continue567}568569// if we already have a stateChar, then it means570// that there was something like ** or +? in there.571// Handle the stateChar, then proceed with this one.572self.debug('call clearStateChar %j', stateChar)573clearStateChar()574stateChar = c575// if extglob is disabled, then +(asdf|foo) isn't a thing.576// just clear the statechar *now*, rather than even diving into577// the patternList stuff.578if (options.noext) clearStateChar()579continue580581case "(":582if (inClass) {583re += "("584continue585}586587if (!stateChar) {588re += "\\("589continue590}591592plType = stateChar593patternListStack.push({ type: plType594, start: i - 1595, reStart: re.length })596// negation is (?:(?!js)[^/]*)597re += stateChar === "!" ? "(?:(?!" : "(?:"598this.debug('plType %j %j', stateChar, re)599stateChar = false600continue601602case ")":603if (inClass || !patternListStack.length) {604re += "\\)"605continue606}607608clearStateChar()609hasMagic = true610re += ")"611plType = patternListStack.pop().type612// negation is (?:(?!js)[^/]*)613// The others are (?:<pattern>)<type>614switch (plType) {615case "!":616re += "[^/]*?)"617break618case "?":619case "+":620case "*": re += plType621case "@": break // the default anyway622}623continue624625case "|":626if (inClass || !patternListStack.length || escaping) {627re += "\\|"628escaping = false629continue630}631632clearStateChar()633re += "|"634continue635636// these are mostly the same in regexp and glob637case "[":638// swallow any state-tracking char before the [639clearStateChar()640641if (inClass) {642re += "\\" + c643continue644}645646inClass = true647classStart = i648reClassStart = re.length649re += c650continue651652case "]":653// a right bracket shall lose its special654// meaning and represent itself in655// a bracket expression if it occurs656// first in the list. -- POSIX.2 2.8.3.2657if (i === classStart + 1 || !inClass) {658re += "\\" + c659escaping = false660continue661}662663// finish up the class.664hasMagic = true665inClass = false666re += c667continue668669default:670// swallow any state char that wasn't consumed671clearStateChar()672673if (escaping) {674// no need675escaping = false676} else if (reSpecials[c]677&& !(c === "^" && inClass)) {678re += "\\"679}680681re += c682683} // switch684} // for685686687// handle the case where we left a class open.688// "[abc" is valid, equivalent to "\[abc"689if (inClass) {690// split where the last [ was, and escape it691// this is a huge pita. We now have to re-walk692// the contents of the would-be class to re-translate693// any characters that were passed through as-is694var cs = pattern.substr(classStart + 1)695, sp = this.parse(cs, SUBPARSE)696re = re.substr(0, reClassStart) + "\\[" + sp[0]697hasMagic = hasMagic || sp[1]698}699700// handle the case where we had a +( thing at the *end*701// of the pattern.702// each pattern list stack adds 3 chars, and we need to go through703// and escape any | chars that were passed through as-is for the regexp.704// Go through and escape them, taking care not to double-escape any705// | chars that were already escaped.706var pl707while (pl = patternListStack.pop()) {708var tail = re.slice(pl.reStart + 3)709// maybe some even number of \, then maybe 1 \, followed by a |710tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {711if (!$2) {712// the | isn't already escaped, so escape it.713$2 = "\\"714}715716// need to escape all those slashes *again*, without escaping the717// one that we need for escaping the | character. As it works out,718// escaping an even number of slashes can be done by simply repeating719// it exactly after itself. That's why this trick works.720//721// I am sorry that you have to see this.722return $1 + $1 + $2 + "|"723})724725this.debug("tail=%j\n %s", tail, tail)726var t = pl.type === "*" ? star727: pl.type === "?" ? qmark728: "\\" + pl.type729730hasMagic = true731re = re.slice(0, pl.reStart)732+ t + "\\("733+ tail734}735736// handle trailing things that only matter at the very end.737clearStateChar()738if (escaping) {739// trailing \\740re += "\\\\"741}742743// only need to apply the nodot start if the re starts with744// something that could conceivably capture a dot745var addPatternStart = false746switch (re.charAt(0)) {747case ".":748case "[":749case "(": addPatternStart = true750}751752// if the re is not "" at this point, then we need to make sure753// it doesn't match against an empty path part.754// Otherwise a/* will match a/, which it should not.755if (re !== "" && hasMagic) re = "(?=.)" + re756757if (addPatternStart) re = patternStart + re758759// parsing just a piece of a larger pattern.760if (isSub === SUBPARSE) {761return [ re, hasMagic ]762}763764// skip the regexp for non-magical patterns765// unescape anything in it, though, so that it'll be766// an exact match against a file etc.767if (!hasMagic) {768return globUnescape(pattern)769}770771var flags = options.nocase ? "i" : ""772, regExp = new RegExp("^" + re + "$", flags)773774regExp._glob = pattern775regExp._src = re776777return regExp778}779780minimatch.makeRe = function (pattern, options) {781return new Minimatch(pattern, options || {}).makeRe()782}783784Minimatch.prototype.makeRe = makeRe785function makeRe () {786if (this.regexp || this.regexp === false) return this.regexp787788// at this point, this.set is a 2d array of partial789// pattern strings, or "**".790//791// It's better to use .match(). This function shouldn't792// be used, really, but it's pretty convenient sometimes,793// when you just want to work with a regex.794var set = this.set795796if (!set.length) return this.regexp = false797var options = this.options798799var twoStar = options.noglobstar ? star800: options.dot ? twoStarDot801: twoStarNoDot802, flags = options.nocase ? "i" : ""803804var re = set.map(function (pattern) {805return pattern.map(function (p) {806return (p === GLOBSTAR) ? twoStar807: (typeof p === "string") ? regExpEscape(p)808: p._src809}).join("\\\/")810}).join("|")811812// must match entire pattern813// ending in a * or ** will make it less strict.814re = "^(?:" + re + ")$"815816// can match anything, as long as it's not this.817if (this.negate) re = "^(?!" + re + ").*$"818819try {820return this.regexp = new RegExp(re, flags)821} catch (ex) {822return this.regexp = false823}824}825826minimatch.match = function (list, pattern, options) {827options = options || {}828var mm = new Minimatch(pattern, options)829list = list.filter(function (f) {830return mm.match(f)831})832if (mm.options.nonull && !list.length) {833list.push(pattern)834}835return list836}837838Minimatch.prototype.match = match839function match (f, partial) {840this.debug("match", f, this.pattern)841// short-circuit in the case of busted things.842// comments, etc.843if (this.comment) return false844if (this.empty) return f === ""845846if (f === "/" && partial) return true847848var options = this.options849850// windows: need to use /, not \851// On other platforms, \ is a valid (albeit bad) filename char.852if (platform === "win32") {853f = f.split("\\").join("/")854}855856// treat the test path as a set of pathparts.857f = f.split(slashSplit)858this.debug(this.pattern, "split", f)859860// just ONE of the pattern sets in this.set needs to match861// in order for it to be valid. If negating, then just one862// match means that we have failed.863// Either way, return on the first hit.864865var set = this.set866this.debug(this.pattern, "set", set)867868// Find the basename of the path by looking for the last non-empty segment869var filename;870for (var i = f.length - 1; i >= 0; i--) {871filename = f[i]872if (filename) break873}874875for (var i = 0, l = set.length; i < l; i ++) {876var pattern = set[i], file = f877if (options.matchBase && pattern.length === 1) {878file = [filename]879}880var hit = this.matchOne(file, pattern, partial)881if (hit) {882if (options.flipNegate) return true883return !this.negate884}885}886887// didn't get any hits. this is success if it's a negative888// pattern, failure otherwise.889if (options.flipNegate) return false890return this.negate891}892893// set partial to true to test if, for example,894// "/a/b" matches the start of "/*/b/*/d"895// Partial means, if you run out of file before you run896// out of pattern, then that's fine, as long as all897// the parts match.898Minimatch.prototype.matchOne = function (file, pattern, partial) {899var options = this.options900901this.debug("matchOne",902{ "this": this903, file: file904, pattern: pattern })905906this.debug("matchOne", file.length, pattern.length)907908for ( var fi = 0909, pi = 0910, fl = file.length911, pl = pattern.length912; (fi < fl) && (pi < pl)913; fi ++, pi ++ ) {914915this.debug("matchOne loop")916var p = pattern[pi]917, f = file[fi]918919this.debug(pattern, p, f)920921// should be impossible.922// some invalid regexp stuff in the set.923if (p === false) return false924925if (p === GLOBSTAR) {926this.debug('GLOBSTAR', [pattern, p, f])927928// "**"929// a/**/b/**/c would match the following:930// a/b/x/y/z/c931// a/x/y/z/b/c932// a/b/x/b/x/c933// a/b/c934// To do this, take the rest of the pattern after935// the **, and see if it would match the file remainder.936// If so, return success.937// If not, the ** "swallows" a segment, and try again.938// This is recursively awful.939//940// a/**/b/**/c matching a/b/x/y/z/c941// - a matches a942// - doublestar943// - matchOne(b/x/y/z/c, b/**/c)944// - b matches b945// - doublestar946// - matchOne(x/y/z/c, c) -> no947// - matchOne(y/z/c, c) -> no948// - matchOne(z/c, c) -> no949// - matchOne(c, c) yes, hit950var fr = fi951, pr = pi + 1952if (pr === pl) {953this.debug('** at the end')954// a ** at the end will just swallow the rest.955// We have found a match.956// however, it will not swallow /.x, unless957// options.dot is set.958// . and .. are *never* matched by **, for explosively959// exponential reasons.960for ( ; fi < fl; fi ++) {961if (file[fi] === "." || file[fi] === ".." ||962(!options.dot && file[fi].charAt(0) === ".")) return false963}964return true965}966967// ok, let's see if we can swallow whatever we can.968WHILE: while (fr < fl) {969var swallowee = file[fr]970971this.debug('\nglobstar while',972file, fr, pattern, pr, swallowee)973974// XXX remove this slice. Just pass the start index.975if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {976this.debug('globstar found match!', fr, fl, swallowee)977// found a match.978return true979} else {980// can't swallow "." or ".." ever.981// can only swallow ".foo" when explicitly asked.982if (swallowee === "." || swallowee === ".." ||983(!options.dot && swallowee.charAt(0) === ".")) {984this.debug("dot detected!", file, fr, pattern, pr)985break WHILE986}987988// ** swallows a segment, and continue.989this.debug('globstar swallow a segment, and continue')990fr ++991}992}993// no match was found.994// However, in partial mode, we can't say this is necessarily over.995// If there's more *pattern* left, then996if (partial) {997// ran out of file998this.debug("\n>>> no match, partial?", file, fr, pattern, pr)999if (fr === fl) return true1000}1001return false1002}10031004// something other than **1005// non-magic patterns just have to match exactly1006// patterns with magic have been turned into regexps.1007var hit1008if (typeof p === "string") {1009if (options.nocase) {1010hit = f.toLowerCase() === p.toLowerCase()1011} else {1012hit = f === p1013}1014this.debug("string match", p, f, hit)1015} else {1016hit = f.match(p)1017this.debug("pattern match", p, f, hit)1018}10191020if (!hit) return false1021}10221023// Note: ending in / means that we'll get a final ""1024// at the end of the pattern. This can only match a1025// corresponding "" at the end of the file.1026// If the file ends in /, then it can only match a1027// a pattern that ends in /, unless the pattern just1028// doesn't have any more for it. But, a/b/ should *not*1029// match "a/b/*", even though "" matches against the1030// [^/]*? pattern, except in partial mode, where it might1031// simply not be reached yet.1032// However, a/b/ should still satisfy a/*10331034// now either we fell off the end of the pattern, or we're done.1035if (fi === fl && pi === pl) {1036// ran out of pattern and filename at the same time.1037// an exact hit!1038return true1039} else if (fi === fl) {1040// ran out of file, but still had pattern left.1041// this is ok if we're doing the match as part of1042// a glob fs traversal.1043return partial1044} else if (pi === pl) {1045// ran out of pattern, still have file left.1046// this is only acceptable if we're on the very last1047// empty segment of a file with a trailing slash.1048// a/* should match a/b/1049var emptyFileEnd = (fi === fl - 1) && (file[fi] === "")1050return emptyFileEnd1051}10521053// should be unreachable.1054throw new Error("wtf?")1055}105610571058// replace stuff like \* with *1059function globUnescape (s) {1060return s.replace(/\\(.)/g, "$1")1061}106210631064function regExpEscape (s) {1065return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")1066}10671068})( typeof require === "function" ? require : null,1069this,1070typeof module === "object" ? module : null,1071typeof process === "object" ? process.platform : "win32"1072)107310741075