minimatch 7.4.2 → 7.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/cjs/_parse.d.ts +7 -0
  2. package/dist/cjs/_parse.d.ts.map +1 -0
  3. package/dist/cjs/_parse.js +300 -0
  4. package/dist/cjs/_parse.js.map +1 -0
  5. package/dist/cjs/assert-valid-pattern.d.ts +2 -0
  6. package/dist/cjs/assert-valid-pattern.d.ts.map +1 -0
  7. package/dist/cjs/assert-valid-pattern.js +14 -0
  8. package/dist/cjs/assert-valid-pattern.js.map +1 -0
  9. package/dist/cjs/brace-expressions.js.map +1 -1
  10. package/dist/cjs/escape.js.map +1 -1
  11. package/dist/cjs/extglob.d.ts +2 -0
  12. package/dist/cjs/extglob.d.ts.map +1 -0
  13. package/dist/cjs/extglob.js +4 -0
  14. package/dist/cjs/extglob.js.map +1 -0
  15. package/dist/cjs/index-cjs.js.map +1 -1
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/parse.d.ts +18 -0
  18. package/dist/cjs/parse.d.ts.map +1 -0
  19. package/dist/cjs/parse.js +650 -0
  20. package/dist/cjs/parse.js.map +1 -0
  21. package/dist/cjs/unescape.js.map +1 -1
  22. package/dist/mjs/_parse.d.ts +7 -0
  23. package/dist/mjs/_parse.d.ts.map +1 -0
  24. package/dist/mjs/_parse.js +296 -0
  25. package/dist/mjs/_parse.js.map +1 -0
  26. package/dist/mjs/assert-valid-pattern.d.ts +2 -0
  27. package/dist/mjs/assert-valid-pattern.d.ts.map +1 -0
  28. package/dist/mjs/assert-valid-pattern.js +10 -0
  29. package/dist/mjs/assert-valid-pattern.js.map +1 -0
  30. package/dist/mjs/brace-expressions.js.map +1 -1
  31. package/dist/mjs/escape.js.map +1 -1
  32. package/dist/mjs/extglob.d.ts +2 -0
  33. package/dist/mjs/extglob.d.ts.map +1 -0
  34. package/dist/mjs/extglob.js +3 -0
  35. package/dist/mjs/extglob.js.map +1 -0
  36. package/dist/mjs/index.js.map +1 -1
  37. package/dist/mjs/parse.d.ts +18 -0
  38. package/dist/mjs/parse.d.ts.map +1 -0
  39. package/dist/mjs/parse.js +646 -0
  40. package/dist/mjs/parse.js.map +1 -0
  41. package/dist/mjs/unescape.js.map +1 -1
  42. package/package.json +1 -1
@@ -0,0 +1,646 @@
1
+ // parse a single path portion
2
+ import { parseClass } from './brace-expressions';
3
+ const types = new Set(['!', '?', '+', '*', '@']);
4
+ const isExtglobType = (c) => types.has(c);
5
+ // characters that indicate a start of pattern needs the "no dots" bit
6
+ const addPatternStart = new Set(['[', '.']);
7
+ const justDots = new Set(['..', '.']);
8
+ const reSpecials = new Set('().*{}+?[]^$\\!');
9
+ const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
10
+ // any single thing other than /
11
+ // don't need to escape / when using new RegExp()
12
+ const qmark = '[^/]';
13
+ // * => any number of characters
14
+ const star = qmark + '*?';
15
+ export class AST {
16
+ type;
17
+ #root;
18
+ #parts = [];
19
+ #parent;
20
+ #parentIndex;
21
+ #negs;
22
+ #filledNegs = false;
23
+ #options;
24
+ constructor(type, parent, options = {}) {
25
+ this.type = type;
26
+ this.#parent = parent;
27
+ this.#root = this.#parent ? this.#parent.#root : this;
28
+ this.#options = this.#root === this ? options : this.#root.#options;
29
+ this.#negs = this.#root === this ? [] : this.#root.#negs;
30
+ if (type === '!' && !this.#root.#filledNegs)
31
+ this.#negs.push(this);
32
+ this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
33
+ }
34
+ fillNegs() {
35
+ if (this !== this.#root) {
36
+ this.#root.fillNegs();
37
+ return this;
38
+ }
39
+ if (this.#filledNegs)
40
+ return this;
41
+ this.#filledNegs = true;
42
+ let n;
43
+ while ((n = this.#negs.pop())) {
44
+ if (n.type !== '!')
45
+ continue;
46
+ // walk up the tree, appending everthing that comes AFTER parentIndex
47
+ let p = n;
48
+ let pp = p.#parent;
49
+ while (pp) {
50
+ for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
51
+ for (const part of n.#parts) {
52
+ /* c8 ignore start */
53
+ if (typeof part === 'string') {
54
+ throw new Error('string part in extglob AST??');
55
+ }
56
+ /* c8 ignore stop */
57
+ part.copyIn(pp.#parts[i]);
58
+ }
59
+ }
60
+ p = pp;
61
+ pp = p.#parent;
62
+ }
63
+ }
64
+ return this;
65
+ }
66
+ push(...parts) {
67
+ for (const p of parts) {
68
+ if (p === '')
69
+ continue;
70
+ /* c8 ignore start */
71
+ if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
72
+ throw new Error('invalid part: ' + p);
73
+ }
74
+ /* c8 ignore stop */
75
+ this.#parts.push(p);
76
+ }
77
+ }
78
+ toJSON() {
79
+ const ret = this.type === null ? this.#parts.slice() : [this.type, ...this.#parts];
80
+ if (this.isStart() && !this.type)
81
+ ret.unshift([]);
82
+ if (this.isEnd() &&
83
+ (this === this.#root ||
84
+ (this.#root.#filledNegs && this.#parent?.type === '!'))) {
85
+ ret.push({});
86
+ }
87
+ return ret;
88
+ }
89
+ isStart() {
90
+ if (this.#root === this)
91
+ return true;
92
+ // if (this.type) return !!this.#parent?.isStart()
93
+ if (!this.#parent?.isStart())
94
+ return false;
95
+ return this.#parentIndex === 0;
96
+ }
97
+ isEnd() {
98
+ if (this.#root === this)
99
+ return true;
100
+ if (this.#parent?.type === '!')
101
+ return true;
102
+ if (!this.#parent?.isEnd())
103
+ return false;
104
+ if (!this.type)
105
+ return this.#parent?.isEnd();
106
+ return (this.#parentIndex === (this.#parent ? this.#parent.#parts.length : 0) - 1);
107
+ }
108
+ copyIn(part) {
109
+ if (typeof part === 'string')
110
+ this.push(part);
111
+ else
112
+ this.push(part.clone(this));
113
+ }
114
+ clone(parent) {
115
+ const c = new AST(this.type, parent);
116
+ for (const p of this.#parts) {
117
+ c.copyIn(p);
118
+ }
119
+ return c;
120
+ }
121
+ static #parseAST(str, ast, pos, opt) {
122
+ let escaping = false;
123
+ if (ast.type === null) {
124
+ // outside of a extglob, append until we find a start
125
+ let i = pos;
126
+ let acc = '';
127
+ while (i < str.length) {
128
+ const c = str.charAt(i++);
129
+ // still accumulate escapes at this point, but we do ignore
130
+ // starts that are escaped
131
+ if (escaping || c === '\\') {
132
+ escaping = !escaping;
133
+ acc += c;
134
+ continue;
135
+ }
136
+ if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
137
+ ast.push(acc);
138
+ acc = '';
139
+ const ext = new AST(c, ast);
140
+ i = AST.#parseAST(str, ext, i, opt);
141
+ ast.push(ext);
142
+ continue;
143
+ }
144
+ acc += c;
145
+ }
146
+ ast.push(acc);
147
+ return i;
148
+ }
149
+ // some kind of extglob, pos is at the (
150
+ // find the next | or )
151
+ let i = pos + 1;
152
+ let part = new AST(null, ast);
153
+ const parts = [];
154
+ let acc = '';
155
+ while (i < str.length) {
156
+ const c = str.charAt(i++);
157
+ // still accumulate escapes at this point, but we do ignore
158
+ // starts that are escaped
159
+ if (escaping || c === '\\') {
160
+ escaping = !escaping;
161
+ acc += c;
162
+ continue;
163
+ }
164
+ if (isExtglobType(c) && str.charAt(i) === '(') {
165
+ part.push(acc);
166
+ acc = '';
167
+ const ext = new AST(c, part);
168
+ part.push(ext);
169
+ i = AST.#parseAST(str, ext, i, opt);
170
+ continue;
171
+ }
172
+ if (c === '|') {
173
+ part.push(acc);
174
+ acc = '';
175
+ parts.push(part);
176
+ part = new AST(null, ast);
177
+ continue;
178
+ }
179
+ if (c === ')') {
180
+ part.push(acc);
181
+ acc = '';
182
+ ast.push(...parts, part);
183
+ return i;
184
+ }
185
+ acc += c;
186
+ }
187
+ // if we got here, it was a malformed extglob! not an extglob, but
188
+ // maybe something else in there.
189
+ ast.type = null;
190
+ ast.#parts = [str.substring(pos)];
191
+ return i;
192
+ }
193
+ static fromGlob(pattern, options = {}) {
194
+ const ast = new AST(null, undefined, options);
195
+ AST.#parseAST(pattern, ast, 0, options);
196
+ console.log('parsed', pattern, JSON.stringify(ast));
197
+ return ast;
198
+ }
199
+ toRegExpSource() {
200
+ if (this.#root === this)
201
+ this.fillNegs();
202
+ if (!this.type) {
203
+ const src = this.#parts
204
+ .map(p => {
205
+ if (typeof p === 'string')
206
+ return AST.#parseGlob(p, this.#options);
207
+ else
208
+ return p.toRegExpSource();
209
+ })
210
+ .join('');
211
+ let start = '';
212
+ if (this.isStart() && typeof this.#parts[0] === 'string') {
213
+ // '.' and '..' cannot match unless the pattern is that exactly
214
+ const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
215
+ if (dotTravAllowed) {
216
+ start = '(?:^|\\/)';
217
+ }
218
+ else {
219
+ const dotsAllowed = this.#options.dot ||
220
+ // no need to prevent dots if it can't match a dot, or if a sub-pattern
221
+ // will be preventing it anyway.
222
+ !addPatternStart.has(src.charAt(0));
223
+ start = dotsAllowed ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))' : '(?!\\.)';
224
+ }
225
+ }
226
+ let end = '';
227
+ if (this.isEnd() &&
228
+ (this === this.#root ||
229
+ (this.#root.#filledNegs && this.#parent?.type === '!'))) {
230
+ end = '(?:$|\\/)';
231
+ }
232
+ return start + src + end;
233
+ }
234
+ // some kind of extglob
235
+ const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
236
+ const body = this.#parts
237
+ .map(p => {
238
+ /* c8 ignore start */
239
+ if (typeof p === 'string') {
240
+ throw new Error('string type in extglob ast??');
241
+ }
242
+ /* c8 ignore stop */
243
+ return p.toRegExpSource();
244
+ })
245
+ .join('|');
246
+ const close = this.type === '!'
247
+ ? '))[^/]*?)'
248
+ : this.type === '@'
249
+ ? ')'
250
+ : `)${this.type}`;
251
+ return start + body + close;
252
+ }
253
+ static #parseGlob(glob, options) {
254
+ let escaping = false;
255
+ let re = '';
256
+ let uflag = false;
257
+ let hasMagic = false;
258
+ for (let i = 0; i < glob.length; i++) {
259
+ const c = glob.charAt(i);
260
+ if (escaping) {
261
+ escaping = false;
262
+ re += (reSpecials.has(c) ? '\\' : '') + c;
263
+ continue;
264
+ }
265
+ if (c === '\\') {
266
+ if (i === glob.length - 1) {
267
+ re += '\\\\';
268
+ }
269
+ else {
270
+ escaping = true;
271
+ }
272
+ continue;
273
+ }
274
+ if (c === '[') {
275
+ const [src, needUflag, consumed, magic] = parseClass(glob, i);
276
+ if (consumed) {
277
+ re += src;
278
+ uflag = uflag || needUflag;
279
+ i += consumed - 1;
280
+ hasMagic = hasMagic || magic;
281
+ continue;
282
+ }
283
+ }
284
+ if (c === '*') {
285
+ re += star;
286
+ hasMagic = true;
287
+ continue;
288
+ }
289
+ if (c === '?') {
290
+ re += qmark;
291
+ hasMagic = true;
292
+ continue;
293
+ }
294
+ re += regExpEscape(c);
295
+ }
296
+ return re;
297
+ }
298
+ }
299
+ const pattern = 'a@(i|w!(x|y)z+(l|m)|j)';
300
+ const ast = AST.fromGlob(pattern).fillNegs();
301
+ console.log('negged', pattern, JSON.stringify(ast));
302
+ console.log('to re src', pattern, ast.toRegExpSource());
303
+ // // the type (exttype or null for strings), and array of children tokens
304
+ //
305
+ // // append everything after a negative extglob to each of the parts
306
+ // // of the negative extglob node. So, eg, [a, [!, x, y], z]
307
+ //
308
+ // //
309
+ // //
310
+ // //
311
+ // //
312
+ //
313
+ // const globUnescape = (s: string) => s.replace(/\\(.)/g, '$1')
314
+ // const regExpEscape = (s: string) =>
315
+ // s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
316
+ //
317
+ // // "abc" -> { a:true, b:true, c:true }
318
+ // const charSet = (s: string) =>
319
+ // s.split('').reduce((set: { [k: string]: boolean }, c) => {
320
+ // set[c] = true
321
+ // return set
322
+ // }, {})
323
+ //
324
+ // // characters that need to be escaped in RegExp.
325
+ // const reSpecials = charSet('().*{}+?[]^$\\!')
326
+ //
327
+ // // characters that indicate we have to add the pattern start
328
+ // const addPatternStartSet = charSet('[.(')
329
+ //
330
+ // // any single thing other than /
331
+ // // don't need to escape / when using new RegExp()
332
+ // const qmark = '[^/]'
333
+ //
334
+ // // * => any number of characters
335
+ // const star = qmark + '*?'
336
+ //
337
+ // // TODO: take an offset and length, so we can sub-parse the extglobs
338
+ // const parse = (
339
+ // options: MinimatchOptions,
340
+ // pattern: string,
341
+ // debug: (...a: any[]) => void
342
+ // ): false | string => {
343
+ // assertValidPattern(pattern)
344
+ //
345
+ // if (pattern === '') return ''
346
+ //
347
+ // let re = ''
348
+ // let hasMagic = false
349
+ // let escaping = false
350
+ // // ? => one single character
351
+ // let uflag = false
352
+ //
353
+ // // . and .. never match anything that doesn't start with .,
354
+ // // even when options.dot is set. However, if the pattern
355
+ // // starts with ., then traversal patterns can match.
356
+ // let dotTravAllowed = pattern.charAt(0) === '.'
357
+ // let dotFileAllowed = options.dot || dotTravAllowed
358
+ // const patternStart = () =>
359
+ // dotTravAllowed
360
+ // ? ''
361
+ // : dotFileAllowed
362
+ // ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
363
+ // : '(?!\\.)'
364
+ // const subPatternStart = (p: string) =>
365
+ // p.charAt(0) === '.'
366
+ // ? ''
367
+ // : options.dot
368
+ // ? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
369
+ // : '(?!\\.)'
370
+ //
371
+ // const clearStateChar = () => {
372
+ // if (stateChar) {
373
+ // // we had some state-tracking character
374
+ // // that wasn't consumed by this pass.
375
+ // switch (stateChar) {
376
+ // case '*':
377
+ // re += star
378
+ // hasMagic = true
379
+ // break
380
+ // case '?':
381
+ // re += qmark
382
+ // hasMagic = true
383
+ // break
384
+ // default:
385
+ // re += '\\' + stateChar
386
+ // break
387
+ // }
388
+ // debug('clearStateChar %j %j', stateChar, re)
389
+ // stateChar = false
390
+ // }
391
+ // }
392
+ //
393
+ // for (
394
+ // let i = 0, c: string;
395
+ // i < pattern.length && (c = pattern.charAt(i));
396
+ // i++
397
+ // ) {
398
+ // debug('%s\t%s %s %j', pattern, i, re, c)
399
+ //
400
+ // // skip over any that are escaped.
401
+ // if (escaping) {
402
+ // // completely not allowed, even escaped.
403
+ // // should be impossible.
404
+ // /* c8 ignore start */
405
+ // if (c === '/') {
406
+ // return false
407
+ // }
408
+ // /* c8 ignore stop */
409
+ //
410
+ // if (reSpecials[c]) {
411
+ // re += '\\'
412
+ // }
413
+ // re += c
414
+ // escaping = false
415
+ // continue
416
+ // }
417
+ //
418
+ // switch (c) {
419
+ // // Should already be path-split by now.
420
+ // /* c8 ignore start */
421
+ // case '/': {
422
+ // return false
423
+ // }
424
+ // /* c8 ignore stop */
425
+ //
426
+ // case '\\':
427
+ // clearStateChar()
428
+ // escaping = true
429
+ // continue
430
+ //
431
+ // // the various stateChar values
432
+ // // for the "extglob" stuff.
433
+ // case '?':
434
+ // case '*':
435
+ // case '+':
436
+ // case '@':
437
+ // case '!':
438
+ // debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c)
439
+ //
440
+ // // if we already have a stateChar, then it means
441
+ // // that there was something like ** or +? in there.
442
+ // // Handle the stateChar, then proceed with this one.
443
+ // debug('call clearStateChar %j', stateChar)
444
+ // clearStateChar()
445
+ // stateChar = c
446
+ // // if extglob is disabled, then +(asdf|foo) isn't a thing.
447
+ // // just clear the statechar *now*, rather than even diving into
448
+ // // the patternList stuff.
449
+ // if (options.noext) clearStateChar()
450
+ // continue
451
+ //
452
+ // case '(': {
453
+ // if (!stateChar) {
454
+ // re += '\\('
455
+ // continue
456
+ // }
457
+ //
458
+ // const plEntry: PatternListEntry = {
459
+ // type: stateChar,
460
+ // start: i - 1,
461
+ // reStart: re.length,
462
+ // open: plTypes[stateChar].open,
463
+ // close: plTypes[stateChar].close,
464
+ // }
465
+ // debug(pattern, '\t', plEntry)
466
+ // patternListStack.push(plEntry)
467
+ // // negation is (?:(?!(?:js)(?:<rest>))[^/]*)
468
+ // re += plEntry.open
469
+ // // next entry starts with a dot maybe?
470
+ // if (plEntry.start === 0 && plEntry.type !== '!') {
471
+ // dotTravAllowed = true
472
+ // re += subPatternStart(pattern.slice(i + 1))
473
+ // }
474
+ // debug('plType %j %j', stateChar, re)
475
+ // stateChar = false
476
+ // continue
477
+ // }
478
+ //
479
+ // case ')': {
480
+ // const plEntry = patternListStack[patternListStack.length - 1]
481
+ // if (!plEntry) {
482
+ // re += '\\)'
483
+ // continue
484
+ // }
485
+ // patternListStack.pop()
486
+ //
487
+ // // closing an extglob
488
+ // clearStateChar()
489
+ // hasMagic = true
490
+ // pl = plEntry
491
+ // // negation is (?:(?!js)[^/]*)
492
+ // // The others are (?:<pattern>)<type>
493
+ // re += pl.close
494
+ // if (pl.type === '!') {
495
+ // negativeLists.push(Object.assign(pl, { reEnd: re.length }))
496
+ // }
497
+ // continue
498
+ // }
499
+ //
500
+ // case '|': {
501
+ // const plEntry = patternListStack[patternListStack.length - 1]
502
+ // if (!plEntry) {
503
+ // re += '\\|'
504
+ // continue
505
+ // }
506
+ //
507
+ // clearStateChar()
508
+ // re += '|'
509
+ // // next subpattern can start with a dot?
510
+ // if (plEntry.start === 0 && plEntry.type !== '!') {
511
+ // dotTravAllowed = true
512
+ // re += subPatternStart(pattern.slice(i + 1))
513
+ // }
514
+ // continue
515
+ // }
516
+ //
517
+ // // these are mostly the same in regexp and glob
518
+ // case '[':
519
+ // // swallow any state-tracking char before the [
520
+ // clearStateChar()
521
+ // const [src, needUflag, consumed, magic] = parseClass(pattern, i)
522
+ // if (consumed) {
523
+ // re += src
524
+ // uflag = uflag || needUflag
525
+ // i += consumed - 1
526
+ // hasMagic = hasMagic || magic
527
+ // } else {
528
+ // re += '\\['
529
+ // }
530
+ // continue
531
+ //
532
+ // case ']':
533
+ // re += '\\' + c
534
+ // continue
535
+ //
536
+ // default:
537
+ // // swallow any state char that wasn't consumed
538
+ // clearStateChar()
539
+ //
540
+ // re += regExpEscape(c)
541
+ // break
542
+ // } // switch
543
+ // } // for
544
+ //
545
+ // // handle the case where we had a +( thing at the *end*
546
+ // // of the pattern.
547
+ // // each pattern list stack adds 3 chars, and we need to go through
548
+ // // and escape any | chars that were passed through as-is for the regexp.
549
+ // // Go through and escape them, taking care not to double-escape any
550
+ // // | chars that were already escaped.
551
+ // for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
552
+ // let tail: string
553
+ // tail = re.slice(pl.reStart + pl.open.length)
554
+ // debug(pattern, 'setting tail', re, pl)
555
+ // // maybe some even number of \, then maybe 1 \, followed by a |
556
+ // tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
557
+ // if (!$2) {
558
+ // // the | isn't already escaped, so escape it.
559
+ // $2 = '\\'
560
+ // // should already be done
561
+ // /* c8 ignore start */
562
+ // }
563
+ // /* c8 ignore stop */
564
+ //
565
+ // // need to escape all those slashes *again*, without escaping the
566
+ // // one that we need for escaping the | character. As it works out,
567
+ // // escaping an even number of slashes can be done by simply repeating
568
+ // // it exactly after itself. That's why this trick works.
569
+ // //
570
+ // // I am sorry that you have to see this.
571
+ // return $1 + $1 + $2 + '|'
572
+ // })
573
+ //
574
+ // debug('tail=%j\n %s', tail, tail, pl, re)
575
+ // const t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type
576
+ //
577
+ // hasMagic = true
578
+ // re = re.slice(0, pl.reStart) + t + '\\(' + tail
579
+ // }
580
+ //
581
+ // // handle trailing things that only matter at the very end.
582
+ // clearStateChar()
583
+ // if (escaping) {
584
+ // // trailing \\
585
+ // re += '\\\\'
586
+ // }
587
+ //
588
+ // // only need to apply the nodot start if the re starts with
589
+ // // something that could conceivably capture a dot
590
+ // const addPatternStart = addPatternStartSet[re.charAt(0)]
591
+ //
592
+ // // Hack to work around lack of negative lookbehind in JS
593
+ // // A pattern like: *.!(x).!(y|z) needs to ensure that a name
594
+ // // like 'a.xyz.yz' doesn't match. So, the first negative
595
+ // // lookahead, has to look ALL the way ahead, to the end of
596
+ // // the pattern.
597
+ // for (let n = negativeLists.length - 1; n > -1; n--) {
598
+ // const nl = negativeLists[n]
599
+ //
600
+ // const nlBefore = re.slice(0, nl.reStart)
601
+ // const nlFirst = re.slice(nl.reStart, nl.reEnd - 8)
602
+ // let nlAfter = re.slice(nl.reEnd)
603
+ // const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter
604
+ //
605
+ // // Handle nested stuff like *(*.js|!(*.json)), where open parens
606
+ // // mean that we should *not* include the ) in the bit that is considered
607
+ // // "after" the negated section.
608
+ // const closeParensBefore = nlBefore.split(')').length
609
+ // const openParensBefore = nlBefore.split('(').length - closeParensBefore
610
+ // let cleanAfter = nlAfter
611
+ // for (let i = 0; i < openParensBefore; i++) {
612
+ // cleanAfter = cleanAfter.replace(/\)[+*?]?/, '')
613
+ // }
614
+ // nlAfter = cleanAfter
615
+ //
616
+ // const dollar = nlAfter === '' ? '(?:$|\\/)' : ''
617
+ //
618
+ // re = nlBefore + nlFirst + nlAfter + dollar + nlLast
619
+ // }
620
+ //
621
+ // // if the re is not "" at this point, then we need to make sure
622
+ // // it doesn't match against an empty path part.
623
+ // // Otherwise a/* will match a/, which it should not.
624
+ // if (re !== '' && hasMagic) {
625
+ // re = '(?=.)' + re
626
+ // }
627
+ //
628
+ // if (addPatternStart) {
629
+ // re = patternStart() + re
630
+ // }
631
+ //
632
+ // // if it's nocase, and the lcase/uppercase don't match, it's magic
633
+ // if (options.nocase && !hasMagic && !options.nocaseMagicOnly) {
634
+ // hasMagic = pattern.toUpperCase() !== pattern.toLowerCase()
635
+ // }
636
+ //
637
+ // // skip the regexp for non-magical patterns
638
+ // // unescape anything in it, though, so that it'll be
639
+ // // an exact match against a file etc.
640
+ // if (!hasMagic) {
641
+ // return globUnescape(re)
642
+ // }
643
+ //
644
+ // return re
645
+ // }
646
+ //# sourceMappingURL=parse.js.map