cf58a3f60cd85058a07d3d338e378618c6cc55ff
[platform/framework/web/crosswalk-tizen.git] /
1 (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2 module.exports = minimatch
3 minimatch.Minimatch = Minimatch
4
5 var isWindows = false
6 if (typeof process !== 'undefined' && process.platform === 'win32')
7   isWindows = true
8
9 var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
10   , expand = require("brace-expansion")
11
12   // any single thing other than /
13   // don't need to escape / when using new RegExp()
14   , qmark = "[^/]"
15
16   // * => any number of characters
17   , star = qmark + "*?"
18
19   // ** when dots are allowed.  Anything goes, except .. and .
20   // not (^ or / followed by one or two dots followed by $ or /),
21   // followed by anything, any number of times.
22   , twoStarDot = "(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?"
23
24   // not a ^ or / followed by a dot,
25   // followed by anything, any number of times.
26   , twoStarNoDot = "(?:(?!(?:\\\/|^)\\.).)*?"
27
28   // characters that need to be escaped in RegExp.
29   , reSpecials = charSet("().*{}+?[]^$\\!")
30
31 // "abc" -> { a:true, b:true, c:true }
32 function charSet (s) {
33   return s.split("").reduce(function (set, c) {
34     set[c] = true
35     return set
36   }, {})
37 }
38
39 // normalizes slashes.
40 var slashSplit = /\/+/
41
42 minimatch.filter = filter
43 function filter (pattern, options) {
44   options = options || {}
45   return function (p, i, list) {
46     return minimatch(p, pattern, options)
47   }
48 }
49
50 function ext (a, b) {
51   a = a || {}
52   b = b || {}
53   var t = {}
54   Object.keys(b).forEach(function (k) {
55     t[k] = b[k]
56   })
57   Object.keys(a).forEach(function (k) {
58     t[k] = a[k]
59   })
60   return t
61 }
62
63 minimatch.defaults = function (def) {
64   if (!def || !Object.keys(def).length) return minimatch
65
66   var orig = minimatch
67
68   var m = function minimatch (p, pattern, options) {
69     return orig.minimatch(p, pattern, ext(def, options))
70   }
71
72   m.Minimatch = function Minimatch (pattern, options) {
73     return new orig.Minimatch(pattern, ext(def, options))
74   }
75
76   return m
77 }
78
79 Minimatch.defaults = function (def) {
80   if (!def || !Object.keys(def).length) return Minimatch
81   return minimatch.defaults(def).Minimatch
82 }
83
84
85 function minimatch (p, pattern, options) {
86   if (typeof pattern !== "string") {
87     throw new TypeError("glob pattern string required")
88   }
89
90   if (!options) options = {}
91
92   // shortcut: comments match nothing.
93   if (!options.nocomment && pattern.charAt(0) === "#") {
94     return false
95   }
96
97   // "" only matches ""
98   if (pattern.trim() === "") return p === ""
99
100   return new Minimatch(pattern, options).match(p)
101 }
102
103 function Minimatch (pattern, options) {
104   if (!(this instanceof Minimatch)) {
105     return new Minimatch(pattern, options)
106   }
107
108   if (typeof pattern !== "string") {
109     throw new TypeError("glob pattern string required")
110   }
111
112   if (!options) options = {}
113   pattern = pattern.trim()
114
115   // windows support: need to use /, not \
116   if (isWindows)
117     pattern = pattern.split("\\").join("/")
118
119   this.options = options
120   this.set = []
121   this.pattern = pattern
122   this.regexp = null
123   this.negate = false
124   this.comment = false
125   this.empty = false
126
127   // make the set of regexps etc.
128   this.make()
129 }
130
131 Minimatch.prototype.debug = function() {}
132
133 Minimatch.prototype.make = make
134 function make () {
135   // don't do it more than once.
136   if (this._made) return
137
138   var pattern = this.pattern
139   var options = this.options
140
141   // empty patterns and comments match nothing.
142   if (!options.nocomment && pattern.charAt(0) === "#") {
143     this.comment = true
144     return
145   }
146   if (!pattern) {
147     this.empty = true
148     return
149   }
150
151   // step 1: figure out negation, etc.
152   this.parseNegate()
153
154   // step 2: expand braces
155   var set = this.globSet = this.braceExpand()
156
157   if (options.debug) this.debug = console.error
158
159   this.debug(this.pattern, set)
160
161   // step 3: now we have a set, so turn each one into a series of path-portion
162   // matching patterns.
163   // These will be regexps, except in the case of "**", which is
164   // set to the GLOBSTAR object for globstar behavior,
165   // and will not contain any / characters
166   set = this.globParts = set.map(function (s) {
167     return s.split(slashSplit)
168   })
169
170   this.debug(this.pattern, set)
171
172   // glob --> regexps
173   set = set.map(function (s, si, set) {
174     return s.map(this.parse, this)
175   }, this)
176
177   this.debug(this.pattern, set)
178
179   // filter out everything that didn't compile properly.
180   set = set.filter(function (s) {
181     return -1 === s.indexOf(false)
182   })
183
184   this.debug(this.pattern, set)
185
186   this.set = set
187 }
188
189 Minimatch.prototype.parseNegate = parseNegate
190 function parseNegate () {
191   var pattern = this.pattern
192     , negate = false
193     , options = this.options
194     , negateOffset = 0
195
196   if (options.nonegate) return
197
198   for ( var i = 0, l = pattern.length
199       ; i < l && pattern.charAt(i) === "!"
200       ; i ++) {
201     negate = !negate
202     negateOffset ++
203   }
204
205   if (negateOffset) this.pattern = pattern.substr(negateOffset)
206   this.negate = negate
207 }
208
209 // Brace expansion:
210 // a{b,c}d -> abd acd
211 // a{b,}c -> abc ac
212 // a{0..3}d -> a0d a1d a2d a3d
213 // a{b,c{d,e}f}g -> abg acdfg acefg
214 // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
215 //
216 // Invalid sets are not expanded.
217 // a{2..}b -> a{2..}b
218 // a{b}c -> a{b}c
219 minimatch.braceExpand = function (pattern, options) {
220   return braceExpand(pattern, options)
221 }
222
223 Minimatch.prototype.braceExpand = braceExpand
224
225 function braceExpand (pattern, options) {
226   if (!options) {
227     if (this instanceof Minimatch)
228       options = this.options
229     else
230       options = {}
231   }
232
233   pattern = typeof pattern === "undefined"
234     ? this.pattern : pattern
235
236   if (typeof pattern === "undefined") {
237     throw new Error("undefined pattern")
238   }
239
240   if (options.nobrace ||
241       !pattern.match(/\{.*\}/)) {
242     // shortcut. no need to expand.
243     return [pattern]
244   }
245
246   return expand(pattern)
247 }
248
249 // parse a component of the expanded set.
250 // At this point, no pattern may contain "/" in it
251 // so we're going to return a 2d array, where each entry is the full
252 // pattern, split on '/', and then turned into a regular expression.
253 // A regexp is made at the end which joins each array with an
254 // escaped /, and another full one which joins each regexp with |.
255 //
256 // Following the lead of Bash 4.1, note that "**" only has special meaning
257 // when it is the *only* thing in a path portion.  Otherwise, any series
258 // of * is equivalent to a single *.  Globstar behavior is enabled by
259 // default, and can be disabled by setting options.noglobstar.
260 Minimatch.prototype.parse = parse
261 var SUBPARSE = {}
262 function parse (pattern, isSub) {
263   var options = this.options
264
265   // shortcuts
266   if (!options.noglobstar && pattern === "**") return GLOBSTAR
267   if (pattern === "") return ""
268
269   var re = ""
270     , hasMagic = !!options.nocase
271     , escaping = false
272     // ? => one single character
273     , patternListStack = []
274     , plType
275     , stateChar
276     , inClass = false
277     , reClassStart = -1
278     , classStart = -1
279     // . and .. never match anything that doesn't start with .,
280     // even when options.dot is set.
281     , patternStart = pattern.charAt(0) === "." ? "" // anything
282       // not (start or / followed by . or .. followed by / or end)
283       : options.dot ? "(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))"
284       : "(?!\\.)"
285     , self = this
286
287   function clearStateChar () {
288     if (stateChar) {
289       // we had some state-tracking character
290       // that wasn't consumed by this pass.
291       switch (stateChar) {
292         case "*":
293           re += star
294           hasMagic = true
295           break
296         case "?":
297           re += qmark
298           hasMagic = true
299           break
300         default:
301           re += "\\"+stateChar
302           break
303       }
304       self.debug('clearStateChar %j %j', stateChar, re)
305       stateChar = false
306     }
307   }
308
309   for ( var i = 0, len = pattern.length, c
310       ; (i < len) && (c = pattern.charAt(i))
311       ; i ++ ) {
312
313     this.debug("%s\t%s %s %j", pattern, i, re, c)
314
315     // skip over any that are escaped.
316     if (escaping && reSpecials[c]) {
317       re += "\\" + c
318       escaping = false
319       continue
320     }
321
322     SWITCH: switch (c) {
323       case "/":
324         // completely not allowed, even escaped.
325         // Should already be path-split by now.
326         return false
327
328       case "\\":
329         clearStateChar()
330         escaping = true
331         continue
332
333       // the various stateChar values
334       // for the "extglob" stuff.
335       case "?":
336       case "*":
337       case "+":
338       case "@":
339       case "!":
340         this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c)
341
342         // all of those are literals inside a class, except that
343         // the glob [!a] means [^a] in regexp
344         if (inClass) {
345           this.debug('  in class')
346           if (c === "!" && i === classStart + 1) c = "^"
347           re += c
348           continue
349         }
350
351         // if we already have a stateChar, then it means
352         // that there was something like ** or +? in there.
353         // Handle the stateChar, then proceed with this one.
354         self.debug('call clearStateChar %j', stateChar)
355         clearStateChar()
356         stateChar = c
357         // if extglob is disabled, then +(asdf|foo) isn't a thing.
358         // just clear the statechar *now*, rather than even diving into
359         // the patternList stuff.
360         if (options.noext) clearStateChar()
361         continue
362
363       case "(":
364         if (inClass) {
365           re += "("
366           continue
367         }
368
369         if (!stateChar) {
370           re += "\\("
371           continue
372         }
373
374         plType = stateChar
375         patternListStack.push({ type: plType
376                               , start: i - 1
377                               , reStart: re.length })
378         // negation is (?:(?!js)[^/]*)
379         re += stateChar === "!" ? "(?:(?!" : "(?:"
380         this.debug('plType %j %j', stateChar, re)
381         stateChar = false
382         continue
383
384       case ")":
385         if (inClass || !patternListStack.length) {
386           re += "\\)"
387           continue
388         }
389
390         clearStateChar()
391         hasMagic = true
392         re += ")"
393         plType = patternListStack.pop().type
394         // negation is (?:(?!js)[^/]*)
395         // The others are (?:<pattern>)<type>
396         switch (plType) {
397           case "!":
398             re += "[^/]*?)"
399             break
400           case "?":
401           case "+":
402           case "*": re += plType
403           case "@": break // the default anyway
404         }
405         continue
406
407       case "|":
408         if (inClass || !patternListStack.length || escaping) {
409           re += "\\|"
410           escaping = false
411           continue
412         }
413
414         clearStateChar()
415         re += "|"
416         continue
417
418       // these are mostly the same in regexp and glob
419       case "[":
420         // swallow any state-tracking char before the [
421         clearStateChar()
422
423         if (inClass) {
424           re += "\\" + c
425           continue
426         }
427
428         inClass = true
429         classStart = i
430         reClassStart = re.length
431         re += c
432         continue
433
434       case "]":
435         //  a right bracket shall lose its special
436         //  meaning and represent itself in
437         //  a bracket expression if it occurs
438         //  first in the list.  -- POSIX.2 2.8.3.2
439         if (i === classStart + 1 || !inClass) {
440           re += "\\" + c
441           escaping = false
442           continue
443         }
444
445         // handle the case where we left a class open.
446         // "[z-a]" is valid, equivalent to "\[z-a\]"
447         if (inClass) {
448           // split where the last [ was, make sure we don't have
449           // an invalid re. if so, re-walk the contents of the
450           // would-be class to re-translate any characters that
451           // were passed through as-is
452           // TODO: It would probably be faster to determine this
453           // without a try/catch and a new RegExp, but it's tricky
454           // to do safely.  For now, this is safe and works.
455           var cs = pattern.substring(classStart + 1, i)
456           try {
457             new RegExp('[' + cs + ']')
458           } catch (er) {
459             // not a valid class!
460             var sp = this.parse(cs, SUBPARSE)
461             re = re.substr(0, reClassStart) + "\\[" + sp[0] + '\\]'
462             hasMagic = hasMagic || sp[1]
463             inClass = false
464             continue
465           }
466         }
467
468         // finish up the class.
469         hasMagic = true
470         inClass = false
471         re += c
472         continue
473
474       default:
475         // swallow any state char that wasn't consumed
476         clearStateChar()
477
478         if (escaping) {
479           // no need
480           escaping = false
481         } else if (reSpecials[c]
482                    && !(c === "^" && inClass)) {
483           re += "\\"
484         }
485
486         re += c
487
488     } // switch
489   } // for
490
491
492   // handle the case where we left a class open.
493   // "[abc" is valid, equivalent to "\[abc"
494   if (inClass) {
495     // split where the last [ was, and escape it
496     // this is a huge pita.  We now have to re-walk
497     // the contents of the would-be class to re-translate
498     // any characters that were passed through as-is
499     var cs = pattern.substr(classStart + 1)
500       , sp = this.parse(cs, SUBPARSE)
501     re = re.substr(0, reClassStart) + "\\[" + sp[0]
502     hasMagic = hasMagic || sp[1]
503   }
504
505   // handle the case where we had a +( thing at the *end*
506   // of the pattern.
507   // each pattern list stack adds 3 chars, and we need to go through
508   // and escape any | chars that were passed through as-is for the regexp.
509   // Go through and escape them, taking care not to double-escape any
510   // | chars that were already escaped.
511   var pl
512   while (pl = patternListStack.pop()) {
513     var tail = re.slice(pl.reStart + 3)
514     // maybe some even number of \, then maybe 1 \, followed by a |
515     tail = tail.replace(/((?:\\{2})*)(\\?)\|/g, function (_, $1, $2) {
516       if (!$2) {
517         // the | isn't already escaped, so escape it.
518         $2 = "\\"
519       }
520
521       // need to escape all those slashes *again*, without escaping the
522       // one that we need for escaping the | character.  As it works out,
523       // escaping an even number of slashes can be done by simply repeating
524       // it exactly after itself.  That's why this trick works.
525       //
526       // I am sorry that you have to see this.
527       return $1 + $1 + $2 + "|"
528     })
529
530     this.debug("tail=%j\n   %s", tail, tail)
531     var t = pl.type === "*" ? star
532           : pl.type === "?" ? qmark
533           : "\\" + pl.type
534
535     hasMagic = true
536     re = re.slice(0, pl.reStart)
537        + t + "\\("
538        + tail
539   }
540
541   // handle trailing things that only matter at the very end.
542   clearStateChar()
543   if (escaping) {
544     // trailing \\
545     re += "\\\\"
546   }
547
548   // only need to apply the nodot start if the re starts with
549   // something that could conceivably capture a dot
550   var addPatternStart = false
551   switch (re.charAt(0)) {
552     case ".":
553     case "[":
554     case "(": addPatternStart = true
555   }
556
557   // if the re is not "" at this point, then we need to make sure
558   // it doesn't match against an empty path part.
559   // Otherwise a/* will match a/, which it should not.
560   if (re !== "" && hasMagic) re = "(?=.)" + re
561
562   if (addPatternStart) re = patternStart + re
563
564   // parsing just a piece of a larger pattern.
565   if (isSub === SUBPARSE) {
566     return [ re, hasMagic ]
567   }
568
569   // skip the regexp for non-magical patterns
570   // unescape anything in it, though, so that it'll be
571   // an exact match against a file etc.
572   if (!hasMagic) {
573     return globUnescape(pattern)
574   }
575
576   var flags = options.nocase ? "i" : ""
577     , regExp = new RegExp("^" + re + "$", flags)
578
579   regExp._glob = pattern
580   regExp._src = re
581
582   return regExp
583 }
584
585 minimatch.makeRe = function (pattern, options) {
586   return new Minimatch(pattern, options || {}).makeRe()
587 }
588
589 Minimatch.prototype.makeRe = makeRe
590 function makeRe () {
591   if (this.regexp || this.regexp === false) return this.regexp
592
593   // at this point, this.set is a 2d array of partial
594   // pattern strings, or "**".
595   //
596   // It's better to use .match().  This function shouldn't
597   // be used, really, but it's pretty convenient sometimes,
598   // when you just want to work with a regex.
599   var set = this.set
600
601   if (!set.length) return this.regexp = false
602   var options = this.options
603
604   var twoStar = options.noglobstar ? star
605       : options.dot ? twoStarDot
606       : twoStarNoDot
607     , flags = options.nocase ? "i" : ""
608
609   var re = set.map(function (pattern) {
610     return pattern.map(function (p) {
611       return (p === GLOBSTAR) ? twoStar
612            : (typeof p === "string") ? regExpEscape(p)
613            : p._src
614     }).join("\\\/")
615   }).join("|")
616
617   // must match entire pattern
618   // ending in a * or ** will make it less strict.
619   re = "^(?:" + re + ")$"
620
621   // can match anything, as long as it's not this.
622   if (this.negate) re = "^(?!" + re + ").*$"
623
624   try {
625     return this.regexp = new RegExp(re, flags)
626   } catch (ex) {
627     return this.regexp = false
628   }
629 }
630
631 minimatch.match = function (list, pattern, options) {
632   options = options || {}
633   var mm = new Minimatch(pattern, options)
634   list = list.filter(function (f) {
635     return mm.match(f)
636   })
637   if (mm.options.nonull && !list.length) {
638     list.push(pattern)
639   }
640   return list
641 }
642
643 Minimatch.prototype.match = match
644 function match (f, partial) {
645   this.debug("match", f, this.pattern)
646   // short-circuit in the case of busted things.
647   // comments, etc.
648   if (this.comment) return false
649   if (this.empty) return f === ""
650
651   if (f === "/" && partial) return true
652
653   var options = this.options
654
655   // windows: need to use /, not \
656   if (isWindows)
657     f = f.split("\\").join("/")
658
659   // treat the test path as a set of pathparts.
660   f = f.split(slashSplit)
661   this.debug(this.pattern, "split", f)
662
663   // just ONE of the pattern sets in this.set needs to match
664   // in order for it to be valid.  If negating, then just one
665   // match means that we have failed.
666   // Either way, return on the first hit.
667
668   var set = this.set
669   this.debug(this.pattern, "set", set)
670
671   // Find the basename of the path by looking for the last non-empty segment
672   var filename;
673   for (var i = f.length - 1; i >= 0; i--) {
674     filename = f[i]
675     if (filename) break
676   }
677
678   for (var i = 0, l = set.length; i < l; i ++) {
679     var pattern = set[i], file = f
680     if (options.matchBase && pattern.length === 1) {
681       file = [filename]
682     }
683     var hit = this.matchOne(file, pattern, partial)
684     if (hit) {
685       if (options.flipNegate) return true
686       return !this.negate
687     }
688   }
689
690   // didn't get any hits.  this is success if it's a negative
691   // pattern, failure otherwise.
692   if (options.flipNegate) return false
693   return this.negate
694 }
695
696 // set partial to true to test if, for example,
697 // "/a/b" matches the start of "/*/b/*/d"
698 // Partial means, if you run out of file before you run
699 // out of pattern, then that's fine, as long as all
700 // the parts match.
701 Minimatch.prototype.matchOne = function (file, pattern, partial) {
702   var options = this.options
703
704   this.debug("matchOne",
705               { "this": this
706               , file: file
707               , pattern: pattern })
708
709   this.debug("matchOne", file.length, pattern.length)
710
711   for ( var fi = 0
712           , pi = 0
713           , fl = file.length
714           , pl = pattern.length
715       ; (fi < fl) && (pi < pl)
716       ; fi ++, pi ++ ) {
717
718     this.debug("matchOne loop")
719     var p = pattern[pi]
720       , f = file[fi]
721
722     this.debug(pattern, p, f)
723
724     // should be impossible.
725     // some invalid regexp stuff in the set.
726     if (p === false) return false
727
728     if (p === GLOBSTAR) {
729       this.debug('GLOBSTAR', [pattern, p, f])
730
731       // "**"
732       // a/**/b/**/c would match the following:
733       // a/b/x/y/z/c
734       // a/x/y/z/b/c
735       // a/b/x/b/x/c
736       // a/b/c
737       // To do this, take the rest of the pattern after
738       // the **, and see if it would match the file remainder.
739       // If so, return success.
740       // If not, the ** "swallows" a segment, and try again.
741       // This is recursively awful.
742       //
743       // a/**/b/**/c matching a/b/x/y/z/c
744       // - a matches a
745       // - doublestar
746       //   - matchOne(b/x/y/z/c, b/**/c)
747       //     - b matches b
748       //     - doublestar
749       //       - matchOne(x/y/z/c, c) -> no
750       //       - matchOne(y/z/c, c) -> no
751       //       - matchOne(z/c, c) -> no
752       //       - matchOne(c, c) yes, hit
753       var fr = fi
754         , pr = pi + 1
755       if (pr === pl) {
756         this.debug('** at the end')
757         // a ** at the end will just swallow the rest.
758         // We have found a match.
759         // however, it will not swallow /.x, unless
760         // options.dot is set.
761         // . and .. are *never* matched by **, for explosively
762         // exponential reasons.
763         for ( ; fi < fl; fi ++) {
764           if (file[fi] === "." || file[fi] === ".." ||
765               (!options.dot && file[fi].charAt(0) === ".")) return false
766         }
767         return true
768       }
769
770       // ok, let's see if we can swallow whatever we can.
771       WHILE: while (fr < fl) {
772         var swallowee = file[fr]
773
774         this.debug('\nglobstar while',
775                     file, fr, pattern, pr, swallowee)
776
777         // XXX remove this slice.  Just pass the start index.
778         if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
779           this.debug('globstar found match!', fr, fl, swallowee)
780           // found a match.
781           return true
782         } else {
783           // can't swallow "." or ".." ever.
784           // can only swallow ".foo" when explicitly asked.
785           if (swallowee === "." || swallowee === ".." ||
786               (!options.dot && swallowee.charAt(0) === ".")) {
787             this.debug("dot detected!", file, fr, pattern, pr)
788             break WHILE
789           }
790
791           // ** swallows a segment, and continue.
792           this.debug('globstar swallow a segment, and continue')
793           fr ++
794         }
795       }
796       // no match was found.
797       // However, in partial mode, we can't say this is necessarily over.
798       // If there's more *pattern* left, then
799       if (partial) {
800         // ran out of file
801         this.debug("\n>>> no match, partial?", file, fr, pattern, pr)
802         if (fr === fl) return true
803       }
804       return false
805     }
806
807     // something other than **
808     // non-magic patterns just have to match exactly
809     // patterns with magic have been turned into regexps.
810     var hit
811     if (typeof p === "string") {
812       if (options.nocase) {
813         hit = f.toLowerCase() === p.toLowerCase()
814       } else {
815         hit = f === p
816       }
817       this.debug("string match", p, f, hit)
818     } else {
819       hit = f.match(p)
820       this.debug("pattern match", p, f, hit)
821     }
822
823     if (!hit) return false
824   }
825
826   // Note: ending in / means that we'll get a final ""
827   // at the end of the pattern.  This can only match a
828   // corresponding "" at the end of the file.
829   // If the file ends in /, then it can only match a
830   // a pattern that ends in /, unless the pattern just
831   // doesn't have any more for it. But, a/b/ should *not*
832   // match "a/b/*", even though "" matches against the
833   // [^/]*? pattern, except in partial mode, where it might
834   // simply not be reached yet.
835   // However, a/b/ should still satisfy a/*
836
837   // now either we fell off the end of the pattern, or we're done.
838   if (fi === fl && pi === pl) {
839     // ran out of pattern and filename at the same time.
840     // an exact hit!
841     return true
842   } else if (fi === fl) {
843     // ran out of file, but still had pattern left.
844     // this is ok if we're doing the match as part of
845     // a glob fs traversal.
846     return partial
847   } else if (pi === pl) {
848     // ran out of pattern, still have file left.
849     // this is only acceptable if we're on the very last
850     // empty segment of a file with a trailing slash.
851     // a/* should match a/b/
852     var emptyFileEnd = (fi === fl - 1) && (file[fi] === "")
853     return emptyFileEnd
854   }
855
856   // should be unreachable.
857   throw new Error("wtf?")
858 }
859
860
861 // replace stuff like \* with *
862 function globUnescape (s) {
863   return s.replace(/\\(.)/g, "$1")
864 }
865
866
867 function regExpEscape (s) {
868   return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&")
869 }
870
871 },{"brace-expansion":2}],2:[function(require,module,exports){
872 var concatMap = require('concat-map');
873 var balanced = require('balanced-match');
874
875 module.exports = expandTop;
876
877 var escSlash = '\0SLASH'+Math.random()+'\0';
878 var escOpen = '\0OPEN'+Math.random()+'\0';
879 var escClose = '\0CLOSE'+Math.random()+'\0';
880 var escComma = '\0COMMA'+Math.random()+'\0';
881 var escPeriod = '\0PERIOD'+Math.random()+'\0';
882
883 function numeric(str) {
884   return parseInt(str, 10) == str
885     ? parseInt(str, 10)
886     : str.charCodeAt(0);
887 }
888
889 function escapeBraces(str) {
890   return str.split('\\\\').join(escSlash)
891             .split('\\{').join(escOpen)
892             .split('\\}').join(escClose)
893             .split('\\,').join(escComma)
894             .split('\\.').join(escPeriod);
895 }
896
897 function unescapeBraces(str) {
898   return str.split(escSlash).join('\\')
899             .split(escOpen).join('{')
900             .split(escClose).join('}')
901             .split(escComma).join(',')
902             .split(escPeriod).join('.');
903 }
904
905
906 // Basically just str.split(","), but handling cases
907 // where we have nested braced sections, which should be
908 // treated as individual members, like {a,{b,c},d}
909 function parseCommaParts(str) {
910   if (!str)
911     return [''];
912
913   var parts = [];
914   var m = balanced('{', '}', str);
915
916   if (!m)
917     return str.split(',');
918
919   var pre = m.pre;
920   var body = m.body;
921   var post = m.post;
922   var p = pre.split(',');
923
924   p[p.length-1] += '{' + body + '}';
925   var postParts = parseCommaParts(post);
926   if (post.length) {
927     p[p.length-1] += postParts.shift();
928     p.push.apply(p, postParts);
929   }
930
931   parts.push.apply(parts, p);
932
933   return parts;
934 }
935
936 function expandTop(str) {
937   if (!str)
938     return [];
939
940   var expansions = expand(escapeBraces(str));
941   return expansions.filter(identity).map(unescapeBraces);
942 }
943
944 function identity(e) {
945   return e;
946 }
947
948 function embrace(str) {
949   return '{' + str + '}';
950 }
951 function isPadded(el) {
952   return /^-?0\d/.test(el);
953 }
954
955 function lte(i, y) {
956   return i <= y;
957 }
958 function gte(i, y) {
959   return i >= y;
960 }
961
962 function expand(str) {
963   var expansions = [];
964
965   var m = balanced('{', '}', str);
966   if (!m || /\$$/.test(m.pre)) return [str];
967
968   var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
969   var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
970   var isSequence = isNumericSequence || isAlphaSequence;
971   var isOptions = /^(.*,)+(.+)?$/.test(m.body);
972   if (!isSequence && !isOptions) {
973     // {a},b}
974     if (m.post.match(/,.*}/)) {
975       str = m.pre + '{' + m.body + escClose + m.post;
976       return expand(str);
977     }
978     return [str];
979   }
980
981   var n;
982   if (isSequence) {
983     n = m.body.split(/\.\./);
984   } else {
985     n = parseCommaParts(m.body);
986     if (n.length === 1) {
987       // x{{a,b}}y ==> x{a}y x{b}y
988       n = expand(n[0]).map(embrace);
989       if (n.length === 1) {
990         var post = m.post.length
991           ? expand(m.post)
992           : [''];
993         return post.map(function(p) {
994           return m.pre + n[0] + p;
995         });
996       }
997     }
998   }
999
1000   // at this point, n is the parts, and we know it's not a comma set
1001   // with a single entry.
1002
1003   // no need to expand pre, since it is guaranteed to be free of brace-sets
1004   var pre = m.pre;
1005   var post = m.post.length
1006     ? expand(m.post)
1007     : [''];
1008
1009   var N;
1010
1011   if (isSequence) {
1012     var x = numeric(n[0]);
1013     var y = numeric(n[1]);
1014     var width = Math.max(n[0].length, n[1].length)
1015     var incr = n.length == 3
1016       ? Math.abs(numeric(n[2]))
1017       : 1;
1018     var test = lte;
1019     var reverse = y < x;
1020     if (reverse) {
1021       incr *= -1;
1022       test = gte;
1023     }
1024     var pad = n.some(isPadded);
1025
1026     N = [];
1027
1028     for (var i = x; test(i, y); i += incr) {
1029       var c;
1030       if (isAlphaSequence) {
1031         c = String.fromCharCode(i);
1032         if (c === '\\')
1033           c = '';
1034       } else {
1035         c = String(i);
1036         if (pad) {
1037           var need = width - c.length;
1038           if (need > 0) {
1039             var z = new Array(need + 1).join('0');
1040             if (i < 0)
1041               c = '-' + z + c.slice(1);
1042             else
1043               c = z + c;
1044           }
1045         }
1046       }
1047       N.push(c);
1048     }
1049   } else {
1050     N = concatMap(n, function(el) { return expand(el) });
1051   }
1052
1053   for (var j = 0; j < N.length; j++) {
1054     for (var k = 0; k < post.length; k++) {
1055       expansions.push([pre, N[j], post[k]].join(''))
1056     }
1057   }
1058
1059   return expansions;
1060 }
1061
1062
1063 },{"balanced-match":3,"concat-map":4}],3:[function(require,module,exports){
1064 module.exports = balanced;
1065 function balanced(a, b, str) {
1066   var bal = 0;
1067   var m = {};
1068   var ended = false;
1069
1070   for (var i = 0; i < str.length; i++) {
1071     if (a == str.substr(i, a.length)) {
1072       if (!('start' in m)) m.start = i;
1073       bal++;
1074     }
1075     else if (b == str.substr(i, b.length) && 'start' in m) {
1076       ended = true;
1077       bal--;
1078       if (!bal) {
1079         m.end = i;
1080         m.pre = str.substr(0, m.start);
1081         m.body = (m.end - m.start > 1)
1082           ? str.substring(m.start + a.length, m.end)
1083           : '';
1084         m.post = str.slice(m.end + b.length);
1085         return m;
1086       }
1087     }
1088   }
1089
1090   // if we opened more than we closed, find the one we closed
1091   if (bal && ended) {
1092     var start = m.start + a.length;
1093     m = balanced(a, b, str.substr(start));
1094     if (m) {
1095       m.start += start;
1096       m.end += start;
1097       m.pre = str.slice(0, start) + m.pre;
1098     }
1099     return m;
1100   }
1101 }
1102
1103 },{}],4:[function(require,module,exports){
1104 module.exports = function (xs, fn) {
1105     var res = [];
1106     for (var i = 0; i < xs.length; i++) {
1107         var x = fn(xs[i], i);
1108         if (Array.isArray(x)) res.push.apply(res, x);
1109         else res.push(x);
1110     }
1111     return res;
1112 };
1113
1114 },{}]},{},[1]);