index.js 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960
  1. module.exports = (function() {
  2. var __MODS__ = {};
  3. var __DEFINE__ = function(modId, func, req) { var m = { exports: {}, _tempexports: {} }; __MODS__[modId] = { status: 0, func: func, req: req, m: m }; };
  4. var __REQUIRE__ = function(modId, source) { if(!__MODS__[modId]) return require(source); if(!__MODS__[modId].status) { var m = __MODS__[modId].m; m._exports = m._tempexports; var desp = Object.getOwnPropertyDescriptor(m, "exports"); if (desp && desp.configurable) Object.defineProperty(m, "exports", { set: function (val) { if(typeof val === "object" && val !== m._exports) { m._exports.__proto__ = val.__proto__; Object.keys(val).forEach(function (k) { m._exports[k] = val[k]; }); } m._tempexports = val }, get: function () { return m._tempexports; } }); __MODS__[modId].status = 1; __MODS__[modId].func(__MODS__[modId].req, m, m.exports); } return __MODS__[modId].m.exports; };
  5. var __REQUIRE_WILDCARD__ = function(obj) { if(obj && obj.__esModule) { return obj; } else { var newObj = {}; if(obj != null) { for(var k in obj) { if (Object.prototype.hasOwnProperty.call(obj, k)) newObj[k] = obj[k]; } } newObj.default = obj; return newObj; } };
  6. var __REQUIRE_DEFAULT__ = function(obj) { return obj && obj.__esModule ? obj.default : obj; };
  7. __DEFINE__(1682324647502, function(require, module, exports) {
  8. module.exports = minimatch
  9. minimatch.Minimatch = Minimatch
  10. var path = (function () { try { return require('path') } catch (e) {}}()) || {
  11. sep: '/'
  12. }
  13. minimatch.sep = path.sep
  14. var GLOBSTAR = minimatch.GLOBSTAR = Minimatch.GLOBSTAR = {}
  15. var expand = require('brace-expansion')
  16. var plTypes = {
  17. '!': { open: '(?:(?!(?:', close: '))[^/]*?)'},
  18. '?': { open: '(?:', close: ')?' },
  19. '+': { open: '(?:', close: ')+' },
  20. '*': { open: '(?:', close: ')*' },
  21. '@': { open: '(?:', close: ')' }
  22. }
  23. // any single thing other than /
  24. // don't need to escape / when using new RegExp()
  25. var qmark = '[^/]'
  26. // * => any number of characters
  27. var star = qmark + '*?'
  28. // ** when dots are allowed. Anything goes, except .. and .
  29. // not (^ or / followed by one or two dots followed by $ or /),
  30. // followed by anything, any number of times.
  31. var twoStarDot = '(?:(?!(?:\\\/|^)(?:\\.{1,2})($|\\\/)).)*?'
  32. // not a ^ or / followed by a dot,
  33. // followed by anything, any number of times.
  34. var twoStarNoDot = '(?:(?!(?:\\\/|^)\\.).)*?'
  35. // characters that need to be escaped in RegExp.
  36. var reSpecials = charSet('().*{}+?[]^$\\!')
  37. // "abc" -> { a:true, b:true, c:true }
  38. function charSet (s) {
  39. return s.split('').reduce(function (set, c) {
  40. set[c] = true
  41. return set
  42. }, {})
  43. }
  44. // normalizes slashes.
  45. var slashSplit = /\/+/
  46. minimatch.filter = filter
  47. function filter (pattern, options) {
  48. options = options || {}
  49. return function (p, i, list) {
  50. return minimatch(p, pattern, options)
  51. }
  52. }
  53. function ext (a, b) {
  54. b = b || {}
  55. var t = {}
  56. Object.keys(a).forEach(function (k) {
  57. t[k] = a[k]
  58. })
  59. Object.keys(b).forEach(function (k) {
  60. t[k] = b[k]
  61. })
  62. return t
  63. }
  64. minimatch.defaults = function (def) {
  65. if (!def || typeof def !== 'object' || !Object.keys(def).length) {
  66. return minimatch
  67. }
  68. var orig = minimatch
  69. var m = function minimatch (p, pattern, options) {
  70. return orig(p, pattern, ext(def, options))
  71. }
  72. m.Minimatch = function Minimatch (pattern, options) {
  73. return new orig.Minimatch(pattern, ext(def, options))
  74. }
  75. m.Minimatch.defaults = function defaults (options) {
  76. return orig.defaults(ext(def, options)).Minimatch
  77. }
  78. m.filter = function filter (pattern, options) {
  79. return orig.filter(pattern, ext(def, options))
  80. }
  81. m.defaults = function defaults (options) {
  82. return orig.defaults(ext(def, options))
  83. }
  84. m.makeRe = function makeRe (pattern, options) {
  85. return orig.makeRe(pattern, ext(def, options))
  86. }
  87. m.braceExpand = function braceExpand (pattern, options) {
  88. return orig.braceExpand(pattern, ext(def, options))
  89. }
  90. m.match = function (list, pattern, options) {
  91. return orig.match(list, pattern, ext(def, options))
  92. }
  93. return m
  94. }
  95. Minimatch.defaults = function (def) {
  96. return minimatch.defaults(def).Minimatch
  97. }
  98. function minimatch (p, pattern, options) {
  99. assertValidPattern(pattern)
  100. if (!options) options = {}
  101. // shortcut: comments match nothing.
  102. if (!options.nocomment && pattern.charAt(0) === '#') {
  103. return false
  104. }
  105. return new Minimatch(pattern, options).match(p)
  106. }
  107. function Minimatch (pattern, options) {
  108. if (!(this instanceof Minimatch)) {
  109. return new Minimatch(pattern, options)
  110. }
  111. assertValidPattern(pattern)
  112. if (!options) options = {}
  113. pattern = pattern.trim()
  114. // windows support: need to use /, not \
  115. if (!options.allowWindowsEscape && path.sep !== '/') {
  116. pattern = pattern.split(path.sep).join('/')
  117. }
  118. this.options = options
  119. this.set = []
  120. this.pattern = pattern
  121. this.regexp = null
  122. this.negate = false
  123. this.comment = false
  124. this.empty = false
  125. this.partial = !!options.partial
  126. // make the set of regexps etc.
  127. this.make()
  128. }
  129. Minimatch.prototype.debug = function () {}
  130. Minimatch.prototype.make = make
  131. function make () {
  132. var pattern = this.pattern
  133. var options = this.options
  134. // empty patterns and comments match nothing.
  135. if (!options.nocomment && pattern.charAt(0) === '#') {
  136. this.comment = true
  137. return
  138. }
  139. if (!pattern) {
  140. this.empty = true
  141. return
  142. }
  143. // step 1: figure out negation, etc.
  144. this.parseNegate()
  145. // step 2: expand braces
  146. var set = this.globSet = this.braceExpand()
  147. if (options.debug) this.debug = function debug() { console.error.apply(console, arguments) }
  148. this.debug(this.pattern, set)
  149. // step 3: now we have a set, so turn each one into a series of path-portion
  150. // matching patterns.
  151. // These will be regexps, except in the case of "**", which is
  152. // set to the GLOBSTAR object for globstar behavior,
  153. // and will not contain any / characters
  154. set = this.globParts = set.map(function (s) {
  155. return s.split(slashSplit)
  156. })
  157. this.debug(this.pattern, set)
  158. // glob --> regexps
  159. set = set.map(function (s, si, set) {
  160. return s.map(this.parse, this)
  161. }, this)
  162. this.debug(this.pattern, set)
  163. // filter out everything that didn't compile properly.
  164. set = set.filter(function (s) {
  165. return s.indexOf(false) === -1
  166. })
  167. this.debug(this.pattern, set)
  168. this.set = set
  169. }
  170. Minimatch.prototype.parseNegate = parseNegate
  171. function parseNegate () {
  172. var pattern = this.pattern
  173. var negate = false
  174. var options = this.options
  175. var negateOffset = 0
  176. if (options.nonegate) return
  177. for (var i = 0, l = pattern.length
  178. ; i < l && pattern.charAt(i) === '!'
  179. ; i++) {
  180. negate = !negate
  181. negateOffset++
  182. }
  183. if (negateOffset) this.pattern = pattern.substr(negateOffset)
  184. this.negate = negate
  185. }
  186. // Brace expansion:
  187. // a{b,c}d -> abd acd
  188. // a{b,}c -> abc ac
  189. // a{0..3}d -> a0d a1d a2d a3d
  190. // a{b,c{d,e}f}g -> abg acdfg acefg
  191. // a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
  192. //
  193. // Invalid sets are not expanded.
  194. // a{2..}b -> a{2..}b
  195. // a{b}c -> a{b}c
  196. minimatch.braceExpand = function (pattern, options) {
  197. return braceExpand(pattern, options)
  198. }
  199. Minimatch.prototype.braceExpand = braceExpand
  200. function braceExpand (pattern, options) {
  201. if (!options) {
  202. if (this instanceof Minimatch) {
  203. options = this.options
  204. } else {
  205. options = {}
  206. }
  207. }
  208. pattern = typeof pattern === 'undefined'
  209. ? this.pattern : pattern
  210. assertValidPattern(pattern)
  211. // Thanks to Yeting Li <https://github.com/yetingli> for
  212. // improving this regexp to avoid a ReDOS vulnerability.
  213. if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
  214. // shortcut. no need to expand.
  215. return [pattern]
  216. }
  217. return expand(pattern)
  218. }
  219. var MAX_PATTERN_LENGTH = 1024 * 64
  220. var assertValidPattern = function (pattern) {
  221. if (typeof pattern !== 'string') {
  222. throw new TypeError('invalid pattern')
  223. }
  224. if (pattern.length > MAX_PATTERN_LENGTH) {
  225. throw new TypeError('pattern is too long')
  226. }
  227. }
  228. // parse a component of the expanded set.
  229. // At this point, no pattern may contain "/" in it
  230. // so we're going to return a 2d array, where each entry is the full
  231. // pattern, split on '/', and then turned into a regular expression.
  232. // A regexp is made at the end which joins each array with an
  233. // escaped /, and another full one which joins each regexp with |.
  234. //
  235. // Following the lead of Bash 4.1, note that "**" only has special meaning
  236. // when it is the *only* thing in a path portion. Otherwise, any series
  237. // of * is equivalent to a single *. Globstar behavior is enabled by
  238. // default, and can be disabled by setting options.noglobstar.
  239. Minimatch.prototype.parse = parse
  240. var SUBPARSE = {}
  241. function parse (pattern, isSub) {
  242. assertValidPattern(pattern)
  243. var options = this.options
  244. // shortcuts
  245. if (pattern === '**') {
  246. if (!options.noglobstar)
  247. return GLOBSTAR
  248. else
  249. pattern = '*'
  250. }
  251. if (pattern === '') return ''
  252. var re = ''
  253. var hasMagic = !!options.nocase
  254. var escaping = false
  255. // ? => one single character
  256. var patternListStack = []
  257. var negativeLists = []
  258. var stateChar
  259. var inClass = false
  260. var reClassStart = -1
  261. var classStart = -1
  262. // . and .. never match anything that doesn't start with .,
  263. // even when options.dot is set.
  264. var patternStart = pattern.charAt(0) === '.' ? '' // anything
  265. // not (start or / followed by . or .. followed by / or end)
  266. : options.dot ? '(?!(?:^|\\\/)\\.{1,2}(?:$|\\\/))'
  267. : '(?!\\.)'
  268. var self = this
  269. function clearStateChar () {
  270. if (stateChar) {
  271. // we had some state-tracking character
  272. // that wasn't consumed by this pass.
  273. switch (stateChar) {
  274. case '*':
  275. re += star
  276. hasMagic = true
  277. break
  278. case '?':
  279. re += qmark
  280. hasMagic = true
  281. break
  282. default:
  283. re += '\\' + stateChar
  284. break
  285. }
  286. self.debug('clearStateChar %j %j', stateChar, re)
  287. stateChar = false
  288. }
  289. }
  290. for (var i = 0, len = pattern.length, c
  291. ; (i < len) && (c = pattern.charAt(i))
  292. ; i++) {
  293. this.debug('%s\t%s %s %j', pattern, i, re, c)
  294. // skip over any that are escaped.
  295. if (escaping && reSpecials[c]) {
  296. re += '\\' + c
  297. escaping = false
  298. continue
  299. }
  300. switch (c) {
  301. /* istanbul ignore next */
  302. case '/': {
  303. // completely not allowed, even escaped.
  304. // Should already be path-split by now.
  305. return false
  306. }
  307. case '\\':
  308. clearStateChar()
  309. escaping = true
  310. continue
  311. // the various stateChar values
  312. // for the "extglob" stuff.
  313. case '?':
  314. case '*':
  315. case '+':
  316. case '@':
  317. case '!':
  318. this.debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
  319. // all of those are literals inside a class, except that
  320. // the glob [!a] means [^a] in regexp
  321. if (inClass) {
  322. this.debug(' in class')
  323. if (c === '!' && i === classStart + 1) c = '^'
  324. re += c
  325. continue
  326. }
  327. // if we already have a stateChar, then it means
  328. // that there was something like ** or +? in there.
  329. // Handle the stateChar, then proceed with this one.
  330. self.debug('call clearStateChar %j', stateChar)
  331. clearStateChar()
  332. stateChar = c
  333. // if extglob is disabled, then +(asdf|foo) isn't a thing.
  334. // just clear the statechar *now*, rather than even diving into
  335. // the patternList stuff.
  336. if (options.noext) clearStateChar()
  337. continue
  338. case '(':
  339. if (inClass) {
  340. re += '('
  341. continue
  342. }
  343. if (!stateChar) {
  344. re += '\\('
  345. continue
  346. }
  347. patternListStack.push({
  348. type: stateChar,
  349. start: i - 1,
  350. reStart: re.length,
  351. open: plTypes[stateChar].open,
  352. close: plTypes[stateChar].close
  353. })
  354. // negation is (?:(?!js)[^/]*)
  355. re += stateChar === '!' ? '(?:(?!(?:' : '(?:'
  356. this.debug('plType %j %j', stateChar, re)
  357. stateChar = false
  358. continue
  359. case ')':
  360. if (inClass || !patternListStack.length) {
  361. re += '\\)'
  362. continue
  363. }
  364. clearStateChar()
  365. hasMagic = true
  366. var pl = patternListStack.pop()
  367. // negation is (?:(?!js)[^/]*)
  368. // The others are (?:<pattern>)<type>
  369. re += pl.close
  370. if (pl.type === '!') {
  371. negativeLists.push(pl)
  372. }
  373. pl.reEnd = re.length
  374. continue
  375. case '|':
  376. if (inClass || !patternListStack.length || escaping) {
  377. re += '\\|'
  378. escaping = false
  379. continue
  380. }
  381. clearStateChar()
  382. re += '|'
  383. continue
  384. // these are mostly the same in regexp and glob
  385. case '[':
  386. // swallow any state-tracking char before the [
  387. clearStateChar()
  388. if (inClass) {
  389. re += '\\' + c
  390. continue
  391. }
  392. inClass = true
  393. classStart = i
  394. reClassStart = re.length
  395. re += c
  396. continue
  397. case ']':
  398. // a right bracket shall lose its special
  399. // meaning and represent itself in
  400. // a bracket expression if it occurs
  401. // first in the list. -- POSIX.2 2.8.3.2
  402. if (i === classStart + 1 || !inClass) {
  403. re += '\\' + c
  404. escaping = false
  405. continue
  406. }
  407. // handle the case where we left a class open.
  408. // "[z-a]" is valid, equivalent to "\[z-a\]"
  409. // split where the last [ was, make sure we don't have
  410. // an invalid re. if so, re-walk the contents of the
  411. // would-be class to re-translate any characters that
  412. // were passed through as-is
  413. // TODO: It would probably be faster to determine this
  414. // without a try/catch and a new RegExp, but it's tricky
  415. // to do safely. For now, this is safe and works.
  416. var cs = pattern.substring(classStart + 1, i)
  417. try {
  418. RegExp('[' + cs + ']')
  419. } catch (er) {
  420. // not a valid class!
  421. var sp = this.parse(cs, SUBPARSE)
  422. re = re.substr(0, reClassStart) + '\\[' + sp[0] + '\\]'
  423. hasMagic = hasMagic || sp[1]
  424. inClass = false
  425. continue
  426. }
  427. // finish up the class.
  428. hasMagic = true
  429. inClass = false
  430. re += c
  431. continue
  432. default:
  433. // swallow any state char that wasn't consumed
  434. clearStateChar()
  435. if (escaping) {
  436. // no need
  437. escaping = false
  438. } else if (reSpecials[c]
  439. && !(c === '^' && inClass)) {
  440. re += '\\'
  441. }
  442. re += c
  443. } // switch
  444. } // for
  445. // handle the case where we left a class open.
  446. // "[abc" is valid, equivalent to "\[abc"
  447. if (inClass) {
  448. // split where the last [ was, and escape it
  449. // this is a huge pita. We now have to re-walk
  450. // the contents of the would-be class to re-translate
  451. // any characters that were passed through as-is
  452. cs = pattern.substr(classStart + 1)
  453. sp = this.parse(cs, SUBPARSE)
  454. re = re.substr(0, reClassStart) + '\\[' + sp[0]
  455. hasMagic = hasMagic || sp[1]
  456. }
  457. // handle the case where we had a +( thing at the *end*
  458. // of the pattern.
  459. // each pattern list stack adds 3 chars, and we need to go through
  460. // and escape any | chars that were passed through as-is for the regexp.
  461. // Go through and escape them, taking care not to double-escape any
  462. // | chars that were already escaped.
  463. for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
  464. var tail = re.slice(pl.reStart + pl.open.length)
  465. this.debug('setting tail', re, pl)
  466. // maybe some even number of \, then maybe 1 \, followed by a |
  467. tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, function (_, $1, $2) {
  468. if (!$2) {
  469. // the | isn't already escaped, so escape it.
  470. $2 = '\\'
  471. }
  472. // need to escape all those slashes *again*, without escaping the
  473. // one that we need for escaping the | character. As it works out,
  474. // escaping an even number of slashes can be done by simply repeating
  475. // it exactly after itself. That's why this trick works.
  476. //
  477. // I am sorry that you have to see this.
  478. return $1 + $1 + $2 + '|'
  479. })
  480. this.debug('tail=%j\n %s', tail, tail, pl, re)
  481. var t = pl.type === '*' ? star
  482. : pl.type === '?' ? qmark
  483. : '\\' + pl.type
  484. hasMagic = true
  485. re = re.slice(0, pl.reStart) + t + '\\(' + tail
  486. }
  487. // handle trailing things that only matter at the very end.
  488. clearStateChar()
  489. if (escaping) {
  490. // trailing \\
  491. re += '\\\\'
  492. }
  493. // only need to apply the nodot start if the re starts with
  494. // something that could conceivably capture a dot
  495. var addPatternStart = false
  496. switch (re.charAt(0)) {
  497. case '[': case '.': case '(': addPatternStart = true
  498. }
  499. // Hack to work around lack of negative lookbehind in JS
  500. // A pattern like: *.!(x).!(y|z) needs to ensure that a name
  501. // like 'a.xyz.yz' doesn't match. So, the first negative
  502. // lookahead, has to look ALL the way ahead, to the end of
  503. // the pattern.
  504. for (var n = negativeLists.length - 1; n > -1; n--) {
  505. var nl = negativeLists[n]
  506. var nlBefore = re.slice(0, nl.reStart)
  507. var nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
  508. var nlLast = re.slice(nl.reEnd - 8, nl.reEnd)
  509. var nlAfter = re.slice(nl.reEnd)
  510. nlLast += nlAfter
  511. // Handle nested stuff like *(*.js|!(*.json)), where open parens
  512. // mean that we should *not* include the ) in the bit that is considered
  513. // "after" the negated section.
  514. var openParensBefore = nlBefore.split('(').length - 1
  515. var cleanAfter = nlAfter
  516. for (i = 0; i < openParensBefore; i++) {
  517. cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
  518. }
  519. nlAfter = cleanAfter
  520. var dollar = ''
  521. if (nlAfter === '' && isSub !== SUBPARSE) {
  522. dollar = '$'
  523. }
  524. var newRe = nlBefore + nlFirst + nlAfter + dollar + nlLast
  525. re = newRe
  526. }
  527. // if the re is not "" at this point, then we need to make sure
  528. // it doesn't match against an empty path part.
  529. // Otherwise a/* will match a/, which it should not.
  530. if (re !== '' && hasMagic) {
  531. re = '(?=.)' + re
  532. }
  533. if (addPatternStart) {
  534. re = patternStart + re
  535. }
  536. // parsing just a piece of a larger pattern.
  537. if (isSub === SUBPARSE) {
  538. return [re, hasMagic]
  539. }
  540. // skip the regexp for non-magical patterns
  541. // unescape anything in it, though, so that it'll be
  542. // an exact match against a file etc.
  543. if (!hasMagic) {
  544. return globUnescape(pattern)
  545. }
  546. var flags = options.nocase ? 'i' : ''
  547. try {
  548. var regExp = new RegExp('^' + re + '$', flags)
  549. } catch (er) /* istanbul ignore next - should be impossible */ {
  550. // If it was an invalid regular expression, then it can't match
  551. // anything. This trick looks for a character after the end of
  552. // the string, which is of course impossible, except in multi-line
  553. // mode, but it's not a /m regex.
  554. return new RegExp('$.')
  555. }
  556. regExp._glob = pattern
  557. regExp._src = re
  558. return regExp
  559. }
  560. minimatch.makeRe = function (pattern, options) {
  561. return new Minimatch(pattern, options || {}).makeRe()
  562. }
  563. Minimatch.prototype.makeRe = makeRe
  564. function makeRe () {
  565. if (this.regexp || this.regexp === false) return this.regexp
  566. // at this point, this.set is a 2d array of partial
  567. // pattern strings, or "**".
  568. //
  569. // It's better to use .match(). This function shouldn't
  570. // be used, really, but it's pretty convenient sometimes,
  571. // when you just want to work with a regex.
  572. var set = this.set
  573. if (!set.length) {
  574. this.regexp = false
  575. return this.regexp
  576. }
  577. var options = this.options
  578. var twoStar = options.noglobstar ? star
  579. : options.dot ? twoStarDot
  580. : twoStarNoDot
  581. var flags = options.nocase ? 'i' : ''
  582. var re = set.map(function (pattern) {
  583. return pattern.map(function (p) {
  584. return (p === GLOBSTAR) ? twoStar
  585. : (typeof p === 'string') ? regExpEscape(p)
  586. : p._src
  587. }).join('\\\/')
  588. }).join('|')
  589. // must match entire pattern
  590. // ending in a * or ** will make it less strict.
  591. re = '^(?:' + re + ')$'
  592. // can match anything, as long as it's not this.
  593. if (this.negate) re = '^(?!' + re + ').*$'
  594. try {
  595. this.regexp = new RegExp(re, flags)
  596. } catch (ex) /* istanbul ignore next - should be impossible */ {
  597. this.regexp = false
  598. }
  599. return this.regexp
  600. }
  601. minimatch.match = function (list, pattern, options) {
  602. options = options || {}
  603. var mm = new Minimatch(pattern, options)
  604. list = list.filter(function (f) {
  605. return mm.match(f)
  606. })
  607. if (mm.options.nonull && !list.length) {
  608. list.push(pattern)
  609. }
  610. return list
  611. }
  612. Minimatch.prototype.match = function match (f, partial) {
  613. if (typeof partial === 'undefined') partial = this.partial
  614. this.debug('match', f, this.pattern)
  615. // short-circuit in the case of busted things.
  616. // comments, etc.
  617. if (this.comment) return false
  618. if (this.empty) return f === ''
  619. if (f === '/' && partial) return true
  620. var options = this.options
  621. // windows: need to use /, not \
  622. if (path.sep !== '/') {
  623. f = f.split(path.sep).join('/')
  624. }
  625. // treat the test path as a set of pathparts.
  626. f = f.split(slashSplit)
  627. this.debug(this.pattern, 'split', f)
  628. // just ONE of the pattern sets in this.set needs to match
  629. // in order for it to be valid. If negating, then just one
  630. // match means that we have failed.
  631. // Either way, return on the first hit.
  632. var set = this.set
  633. this.debug(this.pattern, 'set', set)
  634. // Find the basename of the path by looking for the last non-empty segment
  635. var filename
  636. var i
  637. for (i = f.length - 1; i >= 0; i--) {
  638. filename = f[i]
  639. if (filename) break
  640. }
  641. for (i = 0; i < set.length; i++) {
  642. var pattern = set[i]
  643. var file = f
  644. if (options.matchBase && pattern.length === 1) {
  645. file = [filename]
  646. }
  647. var hit = this.matchOne(file, pattern, partial)
  648. if (hit) {
  649. if (options.flipNegate) return true
  650. return !this.negate
  651. }
  652. }
  653. // didn't get any hits. this is success if it's a negative
  654. // pattern, failure otherwise.
  655. if (options.flipNegate) return false
  656. return this.negate
  657. }
  658. // set partial to true to test if, for example,
  659. // "/a/b" matches the start of "/*/b/*/d"
  660. // Partial means, if you run out of file before you run
  661. // out of pattern, then that's fine, as long as all
  662. // the parts match.
  663. Minimatch.prototype.matchOne = function (file, pattern, partial) {
  664. var options = this.options
  665. this.debug('matchOne',
  666. { 'this': this, file: file, pattern: pattern })
  667. this.debug('matchOne', file.length, pattern.length)
  668. for (var fi = 0,
  669. pi = 0,
  670. fl = file.length,
  671. pl = pattern.length
  672. ; (fi < fl) && (pi < pl)
  673. ; fi++, pi++) {
  674. this.debug('matchOne loop')
  675. var p = pattern[pi]
  676. var f = file[fi]
  677. this.debug(pattern, p, f)
  678. // should be impossible.
  679. // some invalid regexp stuff in the set.
  680. /* istanbul ignore if */
  681. if (p === false) return false
  682. if (p === GLOBSTAR) {
  683. this.debug('GLOBSTAR', [pattern, p, f])
  684. // "**"
  685. // a/**/b/**/c would match the following:
  686. // a/b/x/y/z/c
  687. // a/x/y/z/b/c
  688. // a/b/x/b/x/c
  689. // a/b/c
  690. // To do this, take the rest of the pattern after
  691. // the **, and see if it would match the file remainder.
  692. // If so, return success.
  693. // If not, the ** "swallows" a segment, and try again.
  694. // This is recursively awful.
  695. //
  696. // a/**/b/**/c matching a/b/x/y/z/c
  697. // - a matches a
  698. // - doublestar
  699. // - matchOne(b/x/y/z/c, b/**/c)
  700. // - b matches b
  701. // - doublestar
  702. // - matchOne(x/y/z/c, c) -> no
  703. // - matchOne(y/z/c, c) -> no
  704. // - matchOne(z/c, c) -> no
  705. // - matchOne(c, c) yes, hit
  706. var fr = fi
  707. var pr = pi + 1
  708. if (pr === pl) {
  709. this.debug('** at the end')
  710. // a ** at the end will just swallow the rest.
  711. // We have found a match.
  712. // however, it will not swallow /.x, unless
  713. // options.dot is set.
  714. // . and .. are *never* matched by **, for explosively
  715. // exponential reasons.
  716. for (; fi < fl; fi++) {
  717. if (file[fi] === '.' || file[fi] === '..' ||
  718. (!options.dot && file[fi].charAt(0) === '.')) return false
  719. }
  720. return true
  721. }
  722. // ok, let's see if we can swallow whatever we can.
  723. while (fr < fl) {
  724. var swallowee = file[fr]
  725. this.debug('\nglobstar while', file, fr, pattern, pr, swallowee)
  726. // XXX remove this slice. Just pass the start index.
  727. if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
  728. this.debug('globstar found match!', fr, fl, swallowee)
  729. // found a match.
  730. return true
  731. } else {
  732. // can't swallow "." or ".." ever.
  733. // can only swallow ".foo" when explicitly asked.
  734. if (swallowee === '.' || swallowee === '..' ||
  735. (!options.dot && swallowee.charAt(0) === '.')) {
  736. this.debug('dot detected!', file, fr, pattern, pr)
  737. break
  738. }
  739. // ** swallows a segment, and continue.
  740. this.debug('globstar swallow a segment, and continue')
  741. fr++
  742. }
  743. }
  744. // no match was found.
  745. // However, in partial mode, we can't say this is necessarily over.
  746. // If there's more *pattern* left, then
  747. /* istanbul ignore if */
  748. if (partial) {
  749. // ran out of file
  750. this.debug('\n>>> no match, partial?', file, fr, pattern, pr)
  751. if (fr === fl) return true
  752. }
  753. return false
  754. }
  755. // something other than **
  756. // non-magic patterns just have to match exactly
  757. // patterns with magic have been turned into regexps.
  758. var hit
  759. if (typeof p === 'string') {
  760. hit = f === p
  761. this.debug('string match', p, f, hit)
  762. } else {
  763. hit = f.match(p)
  764. this.debug('pattern match', p, f, hit)
  765. }
  766. if (!hit) return false
  767. }
  768. // Note: ending in / means that we'll get a final ""
  769. // at the end of the pattern. This can only match a
  770. // corresponding "" at the end of the file.
  771. // If the file ends in /, then it can only match a
  772. // a pattern that ends in /, unless the pattern just
  773. // doesn't have any more for it. But, a/b/ should *not*
  774. // match "a/b/*", even though "" matches against the
  775. // [^/]*? pattern, except in partial mode, where it might
  776. // simply not be reached yet.
  777. // However, a/b/ should still satisfy a/*
  778. // now either we fell off the end of the pattern, or we're done.
  779. if (fi === fl && pi === pl) {
  780. // ran out of pattern and filename at the same time.
  781. // an exact hit!
  782. return true
  783. } else if (fi === fl) {
  784. // ran out of file, but still had pattern left.
  785. // this is ok if we're doing the match as part of
  786. // a glob fs traversal.
  787. return partial
  788. } else /* istanbul ignore else */ if (pi === pl) {
  789. // ran out of pattern, still have file left.
  790. // this is only acceptable if we're on the very last
  791. // empty segment of a file with a trailing slash.
  792. // a/* should match a/b/
  793. return (fi === fl - 1) && (file[fi] === '')
  794. }
  795. // should be unreachable.
  796. /* istanbul ignore next */
  797. throw new Error('wtf?')
  798. }
  799. // replace stuff like \* with *
  800. function globUnescape (s) {
  801. return s.replace(/\\(.)/g, '$1')
  802. }
  803. function regExpEscape (s) {
  804. return s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
  805. }
  806. }, function(modId) {var map = {}; return __REQUIRE__(map[modId], modId); })
  807. return __REQUIRE__(1682324647502);
  808. })()
  809. //miniprogram-npm-outsideDeps=["path","brace-expansion"]
  810. //# sourceMappingURL=index.js.map