vitest 0.27.2 → 0.27.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 (36) hide show
  1. package/dist/browser.d.ts +3 -3
  2. package/dist/browser.js +12 -11
  3. package/dist/{chunk-api-setup.029198e3.js → chunk-api-setup.0a2398d8.js} +4 -3
  4. package/dist/{chunk-env-node.787e9561.js → chunk-env-node.ffd1183b.js} +26 -0
  5. package/dist/{chunk-integrations-coverage.44413252.js → chunk-integrations-coverage.18366936.js} +3 -1
  6. package/dist/{chunk-integrations-globals.0024ce21.js → chunk-integrations-globals.59b4d460.js} +7 -6
  7. package/dist/{chunk-mock-date.c543fa3e.js → chunk-mock-date.91595ccd.js} +3 -2
  8. package/dist/{chunk-node-git.125c9008.js → chunk-node-git.59caac18.js} +2 -1
  9. package/dist/{chunk-runtime-chain.2da9e75c.js → chunk-runtime-chain.07d16eac.js} +15 -16
  10. package/dist/{chunk-runtime-error.de671af0.js → chunk-runtime-error.f2062967.js} +1 -1
  11. package/dist/{chunk-runtime-mocker.58511c38.js → chunk-runtime-mocker.66533d65.js} +3 -3
  12. package/dist/{chunk-runtime-rpc.d709e91b.js → chunk-runtime-rpc.e79efa9a.js} +1 -1
  13. package/dist/{chunk-runtime-setup.35da9209.js → chunk-runtime-setup.8ca273cd.js} +17 -13
  14. package/dist/{chunk-snapshot-manager.ce714e21.js → chunk-snapshot-manager.d16903ef.js} +89 -4028
  15. package/dist/{chunk-utils-env.f4a39d2c.js → chunk-utils-env.4ebb0106.js} +1 -0
  16. package/dist/{chunk-utils-import.054ab315.js → chunk-utils-import.eb63557e.js} +3 -3
  17. package/dist/{chunk-utils-source-map.5f5d12cf.js → chunk-utils-source-map.832515f7.js} +2 -2
  18. package/dist/cli-wrapper.js +2 -1
  19. package/dist/cli.js +8 -6
  20. package/dist/config.cjs +10 -7
  21. package/dist/config.d.ts +16 -3
  22. package/dist/config.js +10 -8
  23. package/dist/entry.js +24 -13
  24. package/dist/environments.d.ts +1 -1
  25. package/dist/environments.js +1 -1
  26. package/dist/{index-50755efe.d.ts → index-2dd51af4.d.ts} +1 -1
  27. package/dist/index.d.ts +4 -4
  28. package/dist/index.js +8 -7
  29. package/dist/loader.js +5 -4
  30. package/dist/node.d.ts +2 -2
  31. package/dist/node.js +9 -7
  32. package/dist/suite.js +6 -5
  33. package/dist/{types-d97c72c7.d.ts → types-c1386a7d.d.ts} +332 -308
  34. package/dist/vendor-index.57682f0c.js +3964 -0
  35. package/dist/worker.js +11 -8
  36. package/package.json +7 -6
@@ -1,15 +1,15 @@
1
- import { j as join, c as basename, d as dirname, r as relative, e as extname, b as resolve, f as distDir, g as rootDir, h as isAbsolute, i as isNode, k as configFiles, l as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.f4a39d2c.js';
2
- import { p as pLimit, g as generateHash, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, a as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.44413252.js';
3
- import { g as getEnvPackageName } from './chunk-env-node.787e9561.js';
4
- import { y as ensurePackageInstalled, z as getTasks, A as AggregateErrorPonyfill, s as slash$1, k as relativePath, B as getTests, e as getFullName, u as hasFailed, C as hasFailedSnapshot, D as getSuites, j as notNullish, l as shuffle, t as toArray, n as noop$1, E as deepMerge, b as getCallLastIndex, F as removeUndefinedValues, G as isWindows, H as stdout } from './chunk-mock-date.c543fa3e.js';
1
+ import { j as join, c as basename, d as dirname, r as relative, e as extname, b as resolve, f as distDir, g as rootDir, h as isAbsolute, i as isNode, k as configFiles, l as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.4ebb0106.js';
2
+ import { p as pLimit, g as generateHash, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, a as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.18366936.js';
3
+ import { g as getEnvPackageName } from './chunk-env-node.ffd1183b.js';
4
+ import { y as ensurePackageInstalled, z as getTasks, A as AggregateErrorPonyfill, s as slash$1, k as relativePath, B as getTests, e as getFullName, u as hasFailed, C as hasFailedSnapshot, D as getSuites, j as notNullish, l as shuffle, t as toArray, n as noop$1, E as deepMerge, b as getCallLastIndex, F as removeUndefinedValues, G as isWindows, H as stdout } from './chunk-mock-date.91595ccd.js';
5
5
  import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
6
- import path$a from 'node:path';
6
+ import path$8 from 'node:path';
7
7
  import url, { fileURLToPath } from 'node:url';
8
8
  import process$1 from 'node:process';
9
9
  import fs$8, { promises, existsSync } from 'node:fs';
10
10
  import k from 'path';
11
11
  import require$$0 from 'os';
12
- import util$2 from 'util';
12
+ import { m as micromatch_1 } from './vendor-index.57682f0c.js';
13
13
  import require$$0$1 from 'stream';
14
14
  import require$$2 from 'events';
15
15
  import require$$0$2, { existsSync as existsSync$1, readFileSync } from 'fs';
@@ -21,15 +21,16 @@ import { writeFile, rm } from 'node:fs/promises';
21
21
  import { e as execa } from './vendor-index.451e37bc.js';
22
22
  import { SourceMapConsumer } from 'source-map';
23
23
  import K, { createRequire } from 'module';
24
- import { parse as parse$4 } from 'acorn';
24
+ import { parse } from 'acorn';
25
25
  import { ancestor } from 'acorn-walk';
26
26
  import { MessageChannel } from 'node:worker_threads';
27
27
  import { cpus, hostname } from 'node:os';
28
28
  import { Tinypool } from 'tinypool';
29
29
  import { c as createBirpc } from './vendor-index.783e7f3e.js';
30
30
  import { performance } from 'perf_hooks';
31
- import { s as stripAnsi, c as cliTruncate, b as parseStacktrace, d as stringWidth, e as sliceAnsi, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.5f5d12cf.js';
32
- import { g as safeSetInterval, h as safeClearInterval, s as safeSetTimeout, d as ansiStyles, c as createPatch, a as stringify$5, b as safeClearTimeout } from './chunk-utils-timers.52534f96.js';
31
+ import { s as stripAnsi, c as cliTruncate, b as parseStacktrace, d as stringWidth, e as sliceAnsi, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.832515f7.js';
32
+ import { g as safeSetInterval, h as safeClearInterval, s as safeSetTimeout, d as ansiStyles, c as createPatch, a as stringify, b as safeClearTimeout } from './chunk-utils-timers.52534f96.js';
33
+ import { isCI } from 'std-env';
33
34
  import { resolveModule } from 'local-pkg';
34
35
  import { createHash } from 'crypto';
35
36
  import { slash as slash$2, cleanUrl } from 'vite-node/utils';
@@ -41,7 +42,7 @@ import { stripLiteral } from 'strip-literal';
41
42
  import require$$0$3 from 'readline';
42
43
  import { p as prompts } from './vendor-index.9f20a9be.js';
43
44
 
44
- var version$1 = "0.27.2";
45
+ var version$1 = "0.27.3";
45
46
 
46
47
  class EndError extends Error {
47
48
  constructor(value) {
@@ -124,7 +125,7 @@ async function locatePath(
124
125
 
125
126
  return pLocate(paths, async path_ => {
126
127
  try {
127
- const stat = await statFunction(path$a.resolve(cwd, path_));
128
+ const stat = await statFunction(path$8.resolve(cwd, path_));
128
129
  return matchType(type, stat);
129
130
  } catch {
130
131
  return false;
@@ -137,9 +138,9 @@ const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath)
137
138
  const findUpStop = Symbol('findUpStop');
138
139
 
139
140
  async function findUpMultiple(name, options = {}) {
140
- let directory = path$a.resolve(toPath(options.cwd) || '');
141
- const {root} = path$a.parse(directory);
142
- const stopAt = path$a.resolve(directory, options.stopAt || root);
141
+ let directory = path$8.resolve(toPath(options.cwd) || '');
142
+ const {root} = path$8.parse(directory);
143
+ const stopAt = path$8.resolve(directory, options.stopAt || root);
143
144
  const limit = options.limit || Number.POSITIVE_INFINITY;
144
145
  const paths = [name].flat();
145
146
 
@@ -167,14 +168,14 @@ async function findUpMultiple(name, options = {}) {
167
168
  }
168
169
 
169
170
  if (foundPath) {
170
- matches.push(path$a.resolve(directory, foundPath));
171
+ matches.push(path$8.resolve(directory, foundPath));
171
172
  }
172
173
 
173
174
  if (directory === stopAt || matches.length >= limit) {
174
175
  break;
175
176
  }
176
177
 
177
- directory = path$a.dirname(directory);
178
+ directory = path$8.dirname(directory);
178
179
  }
179
180
 
180
181
  return matches;
@@ -187,7 +188,7 @@ async function findUp(name, options = {}) {
187
188
 
188
189
  var tasks = {};
189
190
 
190
- var utils$k = {};
191
+ var utils$b = {};
191
192
 
192
193
  var array$1 = {};
193
194
 
@@ -243,11 +244,11 @@ function createDirentFromStats$1(name, stats) {
243
244
  }
244
245
  fs$7.createDirentFromStats = createDirentFromStats$1;
245
246
 
246
- var path$9 = {};
247
+ var path$7 = {};
247
248
 
248
- Object.defineProperty(path$9, "__esModule", { value: true });
249
- path$9.removeLeadingDotSegment = path$9.escape = path$9.makeAbsolute = path$9.unixify = void 0;
250
- const path$8 = k;
249
+ Object.defineProperty(path$7, "__esModule", { value: true });
250
+ path$7.removeLeadingDotSegment = path$7.escape = path$7.makeAbsolute = path$7.unixify = void 0;
251
+ const path$6 = k;
251
252
  const LEADING_DOT_SEGMENT_CHARACTERS_COUNT = 2; // ./ or .\\
252
253
  const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
253
254
  /**
@@ -256,15 +257,15 @@ const UNESCAPED_GLOB_SYMBOLS_RE = /(\\?)([()*?[\]{|}]|^!|[!+@](?=\())/g;
256
257
  function unixify(filepath) {
257
258
  return filepath.replace(/\\/g, '/');
258
259
  }
259
- path$9.unixify = unixify;
260
+ path$7.unixify = unixify;
260
261
  function makeAbsolute(cwd, filepath) {
261
- return path$8.resolve(cwd, filepath);
262
+ return path$6.resolve(cwd, filepath);
262
263
  }
263
- path$9.makeAbsolute = makeAbsolute;
264
+ path$7.makeAbsolute = makeAbsolute;
264
265
  function escape(pattern) {
265
266
  return pattern.replace(UNESCAPED_GLOB_SYMBOLS_RE, '\\$2');
266
267
  }
267
- path$9.escape = escape;
268
+ path$7.escape = escape;
268
269
  function removeLeadingDotSegment(entry) {
269
270
  // We do not use `startsWith` because this is 10x slower than current implementation for some cases.
270
271
  // eslint-disable-next-line @typescript-eslint/prefer-string-starts-ends-with
@@ -276,7 +277,7 @@ function removeLeadingDotSegment(entry) {
276
277
  }
277
278
  return entry;
278
279
  }
279
- path$9.removeLeadingDotSegment = removeLeadingDotSegment;
280
+ path$7.removeLeadingDotSegment = removeLeadingDotSegment;
280
281
 
281
282
  var pattern$1 = {};
282
283
 
@@ -493,3966 +494,6 @@ var globParent$1 = function globParent(str, opts) {
493
494
  return str.replace(escaped, '$1');
494
495
  };
495
496
 
496
- var utils$j = {};
497
-
498
- (function (exports) {
499
-
500
- exports.isInteger = num => {
501
- if (typeof num === 'number') {
502
- return Number.isInteger(num);
503
- }
504
- if (typeof num === 'string' && num.trim() !== '') {
505
- return Number.isInteger(Number(num));
506
- }
507
- return false;
508
- };
509
-
510
- /**
511
- * Find a node of the given type
512
- */
513
-
514
- exports.find = (node, type) => node.nodes.find(node => node.type === type);
515
-
516
- /**
517
- * Find a node of the given type
518
- */
519
-
520
- exports.exceedsLimit = (min, max, step = 1, limit) => {
521
- if (limit === false) return false;
522
- if (!exports.isInteger(min) || !exports.isInteger(max)) return false;
523
- return ((Number(max) - Number(min)) / Number(step)) >= limit;
524
- };
525
-
526
- /**
527
- * Escape the given node with '\\' before node.value
528
- */
529
-
530
- exports.escapeNode = (block, n = 0, type) => {
531
- let node = block.nodes[n];
532
- if (!node) return;
533
-
534
- if ((type && node.type === type) || node.type === 'open' || node.type === 'close') {
535
- if (node.escaped !== true) {
536
- node.value = '\\' + node.value;
537
- node.escaped = true;
538
- }
539
- }
540
- };
541
-
542
- /**
543
- * Returns true if the given brace node should be enclosed in literal braces
544
- */
545
-
546
- exports.encloseBrace = node => {
547
- if (node.type !== 'brace') return false;
548
- if ((node.commas >> 0 + node.ranges >> 0) === 0) {
549
- node.invalid = true;
550
- return true;
551
- }
552
- return false;
553
- };
554
-
555
- /**
556
- * Returns true if a brace node is invalid.
557
- */
558
-
559
- exports.isInvalidBrace = block => {
560
- if (block.type !== 'brace') return false;
561
- if (block.invalid === true || block.dollar) return true;
562
- if ((block.commas >> 0 + block.ranges >> 0) === 0) {
563
- block.invalid = true;
564
- return true;
565
- }
566
- if (block.open !== true || block.close !== true) {
567
- block.invalid = true;
568
- return true;
569
- }
570
- return false;
571
- };
572
-
573
- /**
574
- * Returns true if a node is an open or close node
575
- */
576
-
577
- exports.isOpenOrClose = node => {
578
- if (node.type === 'open' || node.type === 'close') {
579
- return true;
580
- }
581
- return node.open === true || node.close === true;
582
- };
583
-
584
- /**
585
- * Reduce an array of text nodes.
586
- */
587
-
588
- exports.reduce = nodes => nodes.reduce((acc, node) => {
589
- if (node.type === 'text') acc.push(node.value);
590
- if (node.type === 'range') node.type = 'text';
591
- return acc;
592
- }, []);
593
-
594
- /**
595
- * Flatten an array
596
- */
597
-
598
- exports.flatten = (...args) => {
599
- const result = [];
600
- const flat = arr => {
601
- for (let i = 0; i < arr.length; i++) {
602
- let ele = arr[i];
603
- Array.isArray(ele) ? flat(ele) : ele !== void 0 && result.push(ele);
604
- }
605
- return result;
606
- };
607
- flat(args);
608
- return result;
609
- };
610
- } (utils$j));
611
-
612
- const utils$i = utils$j;
613
-
614
- var stringify$4 = (ast, options = {}) => {
615
- let stringify = (node, parent = {}) => {
616
- let invalidBlock = options.escapeInvalid && utils$i.isInvalidBrace(parent);
617
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
618
- let output = '';
619
-
620
- if (node.value) {
621
- if ((invalidBlock || invalidNode) && utils$i.isOpenOrClose(node)) {
622
- return '\\' + node.value;
623
- }
624
- return node.value;
625
- }
626
-
627
- if (node.value) {
628
- return node.value;
629
- }
630
-
631
- if (node.nodes) {
632
- for (let child of node.nodes) {
633
- output += stringify(child);
634
- }
635
- }
636
- return output;
637
- };
638
-
639
- return stringify(ast);
640
- };
641
-
642
- /*!
643
- * is-number <https://github.com/jonschlinkert/is-number>
644
- *
645
- * Copyright (c) 2014-present, Jon Schlinkert.
646
- * Released under the MIT License.
647
- */
648
-
649
- var isNumber$2 = function(num) {
650
- if (typeof num === 'number') {
651
- return num - num === 0;
652
- }
653
- if (typeof num === 'string' && num.trim() !== '') {
654
- return Number.isFinite ? Number.isFinite(+num) : isFinite(+num);
655
- }
656
- return false;
657
- };
658
-
659
- /*!
660
- * to-regex-range <https://github.com/micromatch/to-regex-range>
661
- *
662
- * Copyright (c) 2015-present, Jon Schlinkert.
663
- * Released under the MIT License.
664
- */
665
-
666
- const isNumber$1 = isNumber$2;
667
-
668
- const toRegexRange$1 = (min, max, options) => {
669
- if (isNumber$1(min) === false) {
670
- throw new TypeError('toRegexRange: expected the first argument to be a number');
671
- }
672
-
673
- if (max === void 0 || min === max) {
674
- return String(min);
675
- }
676
-
677
- if (isNumber$1(max) === false) {
678
- throw new TypeError('toRegexRange: expected the second argument to be a number.');
679
- }
680
-
681
- let opts = { relaxZeros: true, ...options };
682
- if (typeof opts.strictZeros === 'boolean') {
683
- opts.relaxZeros = opts.strictZeros === false;
684
- }
685
-
686
- let relax = String(opts.relaxZeros);
687
- let shorthand = String(opts.shorthand);
688
- let capture = String(opts.capture);
689
- let wrap = String(opts.wrap);
690
- let cacheKey = min + ':' + max + '=' + relax + shorthand + capture + wrap;
691
-
692
- if (toRegexRange$1.cache.hasOwnProperty(cacheKey)) {
693
- return toRegexRange$1.cache[cacheKey].result;
694
- }
695
-
696
- let a = Math.min(min, max);
697
- let b = Math.max(min, max);
698
-
699
- if (Math.abs(a - b) === 1) {
700
- let result = min + '|' + max;
701
- if (opts.capture) {
702
- return `(${result})`;
703
- }
704
- if (opts.wrap === false) {
705
- return result;
706
- }
707
- return `(?:${result})`;
708
- }
709
-
710
- let isPadded = hasPadding(min) || hasPadding(max);
711
- let state = { min, max, a, b };
712
- let positives = [];
713
- let negatives = [];
714
-
715
- if (isPadded) {
716
- state.isPadded = isPadded;
717
- state.maxLen = String(state.max).length;
718
- }
719
-
720
- if (a < 0) {
721
- let newMin = b < 0 ? Math.abs(b) : 1;
722
- negatives = splitToPatterns(newMin, Math.abs(a), state, opts);
723
- a = state.a = 0;
724
- }
725
-
726
- if (b >= 0) {
727
- positives = splitToPatterns(a, b, state, opts);
728
- }
729
-
730
- state.negatives = negatives;
731
- state.positives = positives;
732
- state.result = collatePatterns(negatives, positives);
733
-
734
- if (opts.capture === true) {
735
- state.result = `(${state.result})`;
736
- } else if (opts.wrap !== false && (positives.length + negatives.length) > 1) {
737
- state.result = `(?:${state.result})`;
738
- }
739
-
740
- toRegexRange$1.cache[cacheKey] = state;
741
- return state.result;
742
- };
743
-
744
- function collatePatterns(neg, pos, options) {
745
- let onlyNegative = filterPatterns(neg, pos, '-', false) || [];
746
- let onlyPositive = filterPatterns(pos, neg, '', false) || [];
747
- let intersected = filterPatterns(neg, pos, '-?', true) || [];
748
- let subpatterns = onlyNegative.concat(intersected).concat(onlyPositive);
749
- return subpatterns.join('|');
750
- }
751
-
752
- function splitToRanges(min, max) {
753
- let nines = 1;
754
- let zeros = 1;
755
-
756
- let stop = countNines(min, nines);
757
- let stops = new Set([max]);
758
-
759
- while (min <= stop && stop <= max) {
760
- stops.add(stop);
761
- nines += 1;
762
- stop = countNines(min, nines);
763
- }
764
-
765
- stop = countZeros(max + 1, zeros) - 1;
766
-
767
- while (min < stop && stop <= max) {
768
- stops.add(stop);
769
- zeros += 1;
770
- stop = countZeros(max + 1, zeros) - 1;
771
- }
772
-
773
- stops = [...stops];
774
- stops.sort(compare);
775
- return stops;
776
- }
777
-
778
- /**
779
- * Convert a range to a regex pattern
780
- * @param {Number} `start`
781
- * @param {Number} `stop`
782
- * @return {String}
783
- */
784
-
785
- function rangeToPattern(start, stop, options) {
786
- if (start === stop) {
787
- return { pattern: start, count: [], digits: 0 };
788
- }
789
-
790
- let zipped = zip(start, stop);
791
- let digits = zipped.length;
792
- let pattern = '';
793
- let count = 0;
794
-
795
- for (let i = 0; i < digits; i++) {
796
- let [startDigit, stopDigit] = zipped[i];
797
-
798
- if (startDigit === stopDigit) {
799
- pattern += startDigit;
800
-
801
- } else if (startDigit !== '0' || stopDigit !== '9') {
802
- pattern += toCharacterClass(startDigit, stopDigit);
803
-
804
- } else {
805
- count++;
806
- }
807
- }
808
-
809
- if (count) {
810
- pattern += options.shorthand === true ? '\\d' : '[0-9]';
811
- }
812
-
813
- return { pattern, count: [count], digits };
814
- }
815
-
816
- function splitToPatterns(min, max, tok, options) {
817
- let ranges = splitToRanges(min, max);
818
- let tokens = [];
819
- let start = min;
820
- let prev;
821
-
822
- for (let i = 0; i < ranges.length; i++) {
823
- let max = ranges[i];
824
- let obj = rangeToPattern(String(start), String(max), options);
825
- let zeros = '';
826
-
827
- if (!tok.isPadded && prev && prev.pattern === obj.pattern) {
828
- if (prev.count.length > 1) {
829
- prev.count.pop();
830
- }
831
-
832
- prev.count.push(obj.count[0]);
833
- prev.string = prev.pattern + toQuantifier(prev.count);
834
- start = max + 1;
835
- continue;
836
- }
837
-
838
- if (tok.isPadded) {
839
- zeros = padZeros(max, tok, options);
840
- }
841
-
842
- obj.string = zeros + obj.pattern + toQuantifier(obj.count);
843
- tokens.push(obj);
844
- start = max + 1;
845
- prev = obj;
846
- }
847
-
848
- return tokens;
849
- }
850
-
851
- function filterPatterns(arr, comparison, prefix, intersection, options) {
852
- let result = [];
853
-
854
- for (let ele of arr) {
855
- let { string } = ele;
856
-
857
- // only push if _both_ are negative...
858
- if (!intersection && !contains(comparison, 'string', string)) {
859
- result.push(prefix + string);
860
- }
861
-
862
- // or _both_ are positive
863
- if (intersection && contains(comparison, 'string', string)) {
864
- result.push(prefix + string);
865
- }
866
- }
867
- return result;
868
- }
869
-
870
- /**
871
- * Zip strings
872
- */
873
-
874
- function zip(a, b) {
875
- let arr = [];
876
- for (let i = 0; i < a.length; i++) arr.push([a[i], b[i]]);
877
- return arr;
878
- }
879
-
880
- function compare(a, b) {
881
- return a > b ? 1 : b > a ? -1 : 0;
882
- }
883
-
884
- function contains(arr, key, val) {
885
- return arr.some(ele => ele[key] === val);
886
- }
887
-
888
- function countNines(min, len) {
889
- return Number(String(min).slice(0, -len) + '9'.repeat(len));
890
- }
891
-
892
- function countZeros(integer, zeros) {
893
- return integer - (integer % Math.pow(10, zeros));
894
- }
895
-
896
- function toQuantifier(digits) {
897
- let [start = 0, stop = ''] = digits;
898
- if (stop || start > 1) {
899
- return `{${start + (stop ? ',' + stop : '')}}`;
900
- }
901
- return '';
902
- }
903
-
904
- function toCharacterClass(a, b, options) {
905
- return `[${a}${(b - a === 1) ? '' : '-'}${b}]`;
906
- }
907
-
908
- function hasPadding(str) {
909
- return /^-?(0+)\d/.test(str);
910
- }
911
-
912
- function padZeros(value, tok, options) {
913
- if (!tok.isPadded) {
914
- return value;
915
- }
916
-
917
- let diff = Math.abs(tok.maxLen - String(value).length);
918
- let relax = options.relaxZeros !== false;
919
-
920
- switch (diff) {
921
- case 0:
922
- return '';
923
- case 1:
924
- return relax ? '0?' : '0';
925
- case 2:
926
- return relax ? '0{0,2}' : '00';
927
- default: {
928
- return relax ? `0{0,${diff}}` : `0{${diff}}`;
929
- }
930
- }
931
- }
932
-
933
- /**
934
- * Cache
935
- */
936
-
937
- toRegexRange$1.cache = {};
938
- toRegexRange$1.clearCache = () => (toRegexRange$1.cache = {});
939
-
940
- /**
941
- * Expose `toRegexRange`
942
- */
943
-
944
- var toRegexRange_1 = toRegexRange$1;
945
-
946
- /*!
947
- * fill-range <https://github.com/jonschlinkert/fill-range>
948
- *
949
- * Copyright (c) 2014-present, Jon Schlinkert.
950
- * Licensed under the MIT License.
951
- */
952
-
953
- const util$1 = util$2;
954
- const toRegexRange = toRegexRange_1;
955
-
956
- const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
957
-
958
- const transform$1 = toNumber => {
959
- return value => toNumber === true ? Number(value) : String(value);
960
- };
961
-
962
- const isValidValue = value => {
963
- return typeof value === 'number' || (typeof value === 'string' && value !== '');
964
- };
965
-
966
- const isNumber = num => Number.isInteger(+num);
967
-
968
- const zeros = input => {
969
- let value = `${input}`;
970
- let index = -1;
971
- if (value[0] === '-') value = value.slice(1);
972
- if (value === '0') return false;
973
- while (value[++index] === '0');
974
- return index > 0;
975
- };
976
-
977
- const stringify$3 = (start, end, options) => {
978
- if (typeof start === 'string' || typeof end === 'string') {
979
- return true;
980
- }
981
- return options.stringify === true;
982
- };
983
-
984
- const pad = (input, maxLength, toNumber) => {
985
- if (maxLength > 0) {
986
- let dash = input[0] === '-' ? '-' : '';
987
- if (dash) input = input.slice(1);
988
- input = (dash + input.padStart(dash ? maxLength - 1 : maxLength, '0'));
989
- }
990
- if (toNumber === false) {
991
- return String(input);
992
- }
993
- return input;
994
- };
995
-
996
- const toMaxLen = (input, maxLength) => {
997
- let negative = input[0] === '-' ? '-' : '';
998
- if (negative) {
999
- input = input.slice(1);
1000
- maxLength--;
1001
- }
1002
- while (input.length < maxLength) input = '0' + input;
1003
- return negative ? ('-' + input) : input;
1004
- };
1005
-
1006
- const toSequence = (parts, options) => {
1007
- parts.negatives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
1008
- parts.positives.sort((a, b) => a < b ? -1 : a > b ? 1 : 0);
1009
-
1010
- let prefix = options.capture ? '' : '?:';
1011
- let positives = '';
1012
- let negatives = '';
1013
- let result;
1014
-
1015
- if (parts.positives.length) {
1016
- positives = parts.positives.join('|');
1017
- }
1018
-
1019
- if (parts.negatives.length) {
1020
- negatives = `-(${prefix}${parts.negatives.join('|')})`;
1021
- }
1022
-
1023
- if (positives && negatives) {
1024
- result = `${positives}|${negatives}`;
1025
- } else {
1026
- result = positives || negatives;
1027
- }
1028
-
1029
- if (options.wrap) {
1030
- return `(${prefix}${result})`;
1031
- }
1032
-
1033
- return result;
1034
- };
1035
-
1036
- const toRange = (a, b, isNumbers, options) => {
1037
- if (isNumbers) {
1038
- return toRegexRange(a, b, { wrap: false, ...options });
1039
- }
1040
-
1041
- let start = String.fromCharCode(a);
1042
- if (a === b) return start;
1043
-
1044
- let stop = String.fromCharCode(b);
1045
- return `[${start}-${stop}]`;
1046
- };
1047
-
1048
- const toRegex = (start, end, options) => {
1049
- if (Array.isArray(start)) {
1050
- let wrap = options.wrap === true;
1051
- let prefix = options.capture ? '' : '?:';
1052
- return wrap ? `(${prefix}${start.join('|')})` : start.join('|');
1053
- }
1054
- return toRegexRange(start, end, options);
1055
- };
1056
-
1057
- const rangeError = (...args) => {
1058
- return new RangeError('Invalid range arguments: ' + util$1.inspect(...args));
1059
- };
1060
-
1061
- const invalidRange = (start, end, options) => {
1062
- if (options.strictRanges === true) throw rangeError([start, end]);
1063
- return [];
1064
- };
1065
-
1066
- const invalidStep = (step, options) => {
1067
- if (options.strictRanges === true) {
1068
- throw new TypeError(`Expected step "${step}" to be a number`);
1069
- }
1070
- return [];
1071
- };
1072
-
1073
- const fillNumbers = (start, end, step = 1, options = {}) => {
1074
- let a = Number(start);
1075
- let b = Number(end);
1076
-
1077
- if (!Number.isInteger(a) || !Number.isInteger(b)) {
1078
- if (options.strictRanges === true) throw rangeError([start, end]);
1079
- return [];
1080
- }
1081
-
1082
- // fix negative zero
1083
- if (a === 0) a = 0;
1084
- if (b === 0) b = 0;
1085
-
1086
- let descending = a > b;
1087
- let startString = String(start);
1088
- let endString = String(end);
1089
- let stepString = String(step);
1090
- step = Math.max(Math.abs(step), 1);
1091
-
1092
- let padded = zeros(startString) || zeros(endString) || zeros(stepString);
1093
- let maxLen = padded ? Math.max(startString.length, endString.length, stepString.length) : 0;
1094
- let toNumber = padded === false && stringify$3(start, end, options) === false;
1095
- let format = options.transform || transform$1(toNumber);
1096
-
1097
- if (options.toRegex && step === 1) {
1098
- return toRange(toMaxLen(start, maxLen), toMaxLen(end, maxLen), true, options);
1099
- }
1100
-
1101
- let parts = { negatives: [], positives: [] };
1102
- let push = num => parts[num < 0 ? 'negatives' : 'positives'].push(Math.abs(num));
1103
- let range = [];
1104
- let index = 0;
1105
-
1106
- while (descending ? a >= b : a <= b) {
1107
- if (options.toRegex === true && step > 1) {
1108
- push(a);
1109
- } else {
1110
- range.push(pad(format(a, index), maxLen, toNumber));
1111
- }
1112
- a = descending ? a - step : a + step;
1113
- index++;
1114
- }
1115
-
1116
- if (options.toRegex === true) {
1117
- return step > 1
1118
- ? toSequence(parts, options)
1119
- : toRegex(range, null, { wrap: false, ...options });
1120
- }
1121
-
1122
- return range;
1123
- };
1124
-
1125
- const fillLetters = (start, end, step = 1, options = {}) => {
1126
- if ((!isNumber(start) && start.length > 1) || (!isNumber(end) && end.length > 1)) {
1127
- return invalidRange(start, end, options);
1128
- }
1129
-
1130
-
1131
- let format = options.transform || (val => String.fromCharCode(val));
1132
- let a = `${start}`.charCodeAt(0);
1133
- let b = `${end}`.charCodeAt(0);
1134
-
1135
- let descending = a > b;
1136
- let min = Math.min(a, b);
1137
- let max = Math.max(a, b);
1138
-
1139
- if (options.toRegex && step === 1) {
1140
- return toRange(min, max, false, options);
1141
- }
1142
-
1143
- let range = [];
1144
- let index = 0;
1145
-
1146
- while (descending ? a >= b : a <= b) {
1147
- range.push(format(a, index));
1148
- a = descending ? a - step : a + step;
1149
- index++;
1150
- }
1151
-
1152
- if (options.toRegex === true) {
1153
- return toRegex(range, null, { wrap: false, options });
1154
- }
1155
-
1156
- return range;
1157
- };
1158
-
1159
- const fill$2 = (start, end, step, options = {}) => {
1160
- if (end == null && isValidValue(start)) {
1161
- return [start];
1162
- }
1163
-
1164
- if (!isValidValue(start) || !isValidValue(end)) {
1165
- return invalidRange(start, end, options);
1166
- }
1167
-
1168
- if (typeof step === 'function') {
1169
- return fill$2(start, end, 1, { transform: step });
1170
- }
1171
-
1172
- if (isObject$1(step)) {
1173
- return fill$2(start, end, 0, step);
1174
- }
1175
-
1176
- let opts = { ...options };
1177
- if (opts.capture === true) opts.wrap = true;
1178
- step = step || opts.step || 1;
1179
-
1180
- if (!isNumber(step)) {
1181
- if (step != null && !isObject$1(step)) return invalidStep(step, opts);
1182
- return fill$2(start, end, 1, step);
1183
- }
1184
-
1185
- if (isNumber(start) && isNumber(end)) {
1186
- return fillNumbers(start, end, step, opts);
1187
- }
1188
-
1189
- return fillLetters(start, end, Math.max(Math.abs(step), 1), opts);
1190
- };
1191
-
1192
- var fillRange = fill$2;
1193
-
1194
- const fill$1 = fillRange;
1195
- const utils$h = utils$j;
1196
-
1197
- const compile$1 = (ast, options = {}) => {
1198
- let walk = (node, parent = {}) => {
1199
- let invalidBlock = utils$h.isInvalidBrace(parent);
1200
- let invalidNode = node.invalid === true && options.escapeInvalid === true;
1201
- let invalid = invalidBlock === true || invalidNode === true;
1202
- let prefix = options.escapeInvalid === true ? '\\' : '';
1203
- let output = '';
1204
-
1205
- if (node.isOpen === true) {
1206
- return prefix + node.value;
1207
- }
1208
- if (node.isClose === true) {
1209
- return prefix + node.value;
1210
- }
1211
-
1212
- if (node.type === 'open') {
1213
- return invalid ? (prefix + node.value) : '(';
1214
- }
1215
-
1216
- if (node.type === 'close') {
1217
- return invalid ? (prefix + node.value) : ')';
1218
- }
1219
-
1220
- if (node.type === 'comma') {
1221
- return node.prev.type === 'comma' ? '' : (invalid ? node.value : '|');
1222
- }
1223
-
1224
- if (node.value) {
1225
- return node.value;
1226
- }
1227
-
1228
- if (node.nodes && node.ranges > 0) {
1229
- let args = utils$h.reduce(node.nodes);
1230
- let range = fill$1(...args, { ...options, wrap: false, toRegex: true });
1231
-
1232
- if (range.length !== 0) {
1233
- return args.length > 1 && range.length > 1 ? `(${range})` : range;
1234
- }
1235
- }
1236
-
1237
- if (node.nodes) {
1238
- for (let child of node.nodes) {
1239
- output += walk(child, node);
1240
- }
1241
- }
1242
- return output;
1243
- };
1244
-
1245
- return walk(ast);
1246
- };
1247
-
1248
- var compile_1 = compile$1;
1249
-
1250
- const fill = fillRange;
1251
- const stringify$2 = stringify$4;
1252
- const utils$g = utils$j;
1253
-
1254
- const append = (queue = '', stash = '', enclose = false) => {
1255
- let result = [];
1256
-
1257
- queue = [].concat(queue);
1258
- stash = [].concat(stash);
1259
-
1260
- if (!stash.length) return queue;
1261
- if (!queue.length) {
1262
- return enclose ? utils$g.flatten(stash).map(ele => `{${ele}}`) : stash;
1263
- }
1264
-
1265
- for (let item of queue) {
1266
- if (Array.isArray(item)) {
1267
- for (let value of item) {
1268
- result.push(append(value, stash, enclose));
1269
- }
1270
- } else {
1271
- for (let ele of stash) {
1272
- if (enclose === true && typeof ele === 'string') ele = `{${ele}}`;
1273
- result.push(Array.isArray(ele) ? append(item, ele, enclose) : (item + ele));
1274
- }
1275
- }
1276
- }
1277
- return utils$g.flatten(result);
1278
- };
1279
-
1280
- const expand$1 = (ast, options = {}) => {
1281
- let rangeLimit = options.rangeLimit === void 0 ? 1000 : options.rangeLimit;
1282
-
1283
- let walk = (node, parent = {}) => {
1284
- node.queue = [];
1285
-
1286
- let p = parent;
1287
- let q = parent.queue;
1288
-
1289
- while (p.type !== 'brace' && p.type !== 'root' && p.parent) {
1290
- p = p.parent;
1291
- q = p.queue;
1292
- }
1293
-
1294
- if (node.invalid || node.dollar) {
1295
- q.push(append(q.pop(), stringify$2(node, options)));
1296
- return;
1297
- }
1298
-
1299
- if (node.type === 'brace' && node.invalid !== true && node.nodes.length === 2) {
1300
- q.push(append(q.pop(), ['{}']));
1301
- return;
1302
- }
1303
-
1304
- if (node.nodes && node.ranges > 0) {
1305
- let args = utils$g.reduce(node.nodes);
1306
-
1307
- if (utils$g.exceedsLimit(...args, options.step, rangeLimit)) {
1308
- throw new RangeError('expanded array length exceeds range limit. Use options.rangeLimit to increase or disable the limit.');
1309
- }
1310
-
1311
- let range = fill(...args, options);
1312
- if (range.length === 0) {
1313
- range = stringify$2(node, options);
1314
- }
1315
-
1316
- q.push(append(q.pop(), range));
1317
- node.nodes = [];
1318
- return;
1319
- }
1320
-
1321
- let enclose = utils$g.encloseBrace(node);
1322
- let queue = node.queue;
1323
- let block = node;
1324
-
1325
- while (block.type !== 'brace' && block.type !== 'root' && block.parent) {
1326
- block = block.parent;
1327
- queue = block.queue;
1328
- }
1329
-
1330
- for (let i = 0; i < node.nodes.length; i++) {
1331
- let child = node.nodes[i];
1332
-
1333
- if (child.type === 'comma' && node.type === 'brace') {
1334
- if (i === 1) queue.push('');
1335
- queue.push('');
1336
- continue;
1337
- }
1338
-
1339
- if (child.type === 'close') {
1340
- q.push(append(q.pop(), queue, enclose));
1341
- continue;
1342
- }
1343
-
1344
- if (child.value && child.type !== 'open') {
1345
- queue.push(append(queue.pop(), child.value));
1346
- continue;
1347
- }
1348
-
1349
- if (child.nodes) {
1350
- walk(child, node);
1351
- }
1352
- }
1353
-
1354
- return queue;
1355
- };
1356
-
1357
- return utils$g.flatten(walk(ast));
1358
- };
1359
-
1360
- var expand_1 = expand$1;
1361
-
1362
- var constants$4 = {
1363
- MAX_LENGTH: 1024 * 64,
1364
-
1365
- // Digits
1366
- CHAR_0: '0', /* 0 */
1367
- CHAR_9: '9', /* 9 */
1368
-
1369
- // Alphabet chars.
1370
- CHAR_UPPERCASE_A: 'A', /* A */
1371
- CHAR_LOWERCASE_A: 'a', /* a */
1372
- CHAR_UPPERCASE_Z: 'Z', /* Z */
1373
- CHAR_LOWERCASE_Z: 'z', /* z */
1374
-
1375
- CHAR_LEFT_PARENTHESES: '(', /* ( */
1376
- CHAR_RIGHT_PARENTHESES: ')', /* ) */
1377
-
1378
- CHAR_ASTERISK: '*', /* * */
1379
-
1380
- // Non-alphabetic chars.
1381
- CHAR_AMPERSAND: '&', /* & */
1382
- CHAR_AT: '@', /* @ */
1383
- CHAR_BACKSLASH: '\\', /* \ */
1384
- CHAR_BACKTICK: '`', /* ` */
1385
- CHAR_CARRIAGE_RETURN: '\r', /* \r */
1386
- CHAR_CIRCUMFLEX_ACCENT: '^', /* ^ */
1387
- CHAR_COLON: ':', /* : */
1388
- CHAR_COMMA: ',', /* , */
1389
- CHAR_DOLLAR: '$', /* . */
1390
- CHAR_DOT: '.', /* . */
1391
- CHAR_DOUBLE_QUOTE: '"', /* " */
1392
- CHAR_EQUAL: '=', /* = */
1393
- CHAR_EXCLAMATION_MARK: '!', /* ! */
1394
- CHAR_FORM_FEED: '\f', /* \f */
1395
- CHAR_FORWARD_SLASH: '/', /* / */
1396
- CHAR_HASH: '#', /* # */
1397
- CHAR_HYPHEN_MINUS: '-', /* - */
1398
- CHAR_LEFT_ANGLE_BRACKET: '<', /* < */
1399
- CHAR_LEFT_CURLY_BRACE: '{', /* { */
1400
- CHAR_LEFT_SQUARE_BRACKET: '[', /* [ */
1401
- CHAR_LINE_FEED: '\n', /* \n */
1402
- CHAR_NO_BREAK_SPACE: '\u00A0', /* \u00A0 */
1403
- CHAR_PERCENT: '%', /* % */
1404
- CHAR_PLUS: '+', /* + */
1405
- CHAR_QUESTION_MARK: '?', /* ? */
1406
- CHAR_RIGHT_ANGLE_BRACKET: '>', /* > */
1407
- CHAR_RIGHT_CURLY_BRACE: '}', /* } */
1408
- CHAR_RIGHT_SQUARE_BRACKET: ']', /* ] */
1409
- CHAR_SEMICOLON: ';', /* ; */
1410
- CHAR_SINGLE_QUOTE: '\'', /* ' */
1411
- CHAR_SPACE: ' ', /* */
1412
- CHAR_TAB: '\t', /* \t */
1413
- CHAR_UNDERSCORE: '_', /* _ */
1414
- CHAR_VERTICAL_LINE: '|', /* | */
1415
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: '\uFEFF' /* \uFEFF */
1416
- };
1417
-
1418
- const stringify$1 = stringify$4;
1419
-
1420
- /**
1421
- * Constants
1422
- */
1423
-
1424
- const {
1425
- MAX_LENGTH: MAX_LENGTH$1,
1426
- CHAR_BACKSLASH, /* \ */
1427
- CHAR_BACKTICK, /* ` */
1428
- CHAR_COMMA: CHAR_COMMA$1, /* , */
1429
- CHAR_DOT: CHAR_DOT$1, /* . */
1430
- CHAR_LEFT_PARENTHESES: CHAR_LEFT_PARENTHESES$1, /* ( */
1431
- CHAR_RIGHT_PARENTHESES: CHAR_RIGHT_PARENTHESES$1, /* ) */
1432
- CHAR_LEFT_CURLY_BRACE: CHAR_LEFT_CURLY_BRACE$1, /* { */
1433
- CHAR_RIGHT_CURLY_BRACE: CHAR_RIGHT_CURLY_BRACE$1, /* } */
1434
- CHAR_LEFT_SQUARE_BRACKET: CHAR_LEFT_SQUARE_BRACKET$1, /* [ */
1435
- CHAR_RIGHT_SQUARE_BRACKET: CHAR_RIGHT_SQUARE_BRACKET$1, /* ] */
1436
- CHAR_DOUBLE_QUOTE, /* " */
1437
- CHAR_SINGLE_QUOTE, /* ' */
1438
- CHAR_NO_BREAK_SPACE,
1439
- CHAR_ZERO_WIDTH_NOBREAK_SPACE
1440
- } = constants$4;
1441
-
1442
- /**
1443
- * parse
1444
- */
1445
-
1446
- const parse$3 = (input, options = {}) => {
1447
- if (typeof input !== 'string') {
1448
- throw new TypeError('Expected a string');
1449
- }
1450
-
1451
- let opts = options || {};
1452
- let max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH$1, opts.maxLength) : MAX_LENGTH$1;
1453
- if (input.length > max) {
1454
- throw new SyntaxError(`Input length (${input.length}), exceeds max characters (${max})`);
1455
- }
1456
-
1457
- let ast = { type: 'root', input, nodes: [] };
1458
- let stack = [ast];
1459
- let block = ast;
1460
- let prev = ast;
1461
- let brackets = 0;
1462
- let length = input.length;
1463
- let index = 0;
1464
- let depth = 0;
1465
- let value;
1466
-
1467
- /**
1468
- * Helpers
1469
- */
1470
-
1471
- const advance = () => input[index++];
1472
- const push = node => {
1473
- if (node.type === 'text' && prev.type === 'dot') {
1474
- prev.type = 'text';
1475
- }
1476
-
1477
- if (prev && prev.type === 'text' && node.type === 'text') {
1478
- prev.value += node.value;
1479
- return;
1480
- }
1481
-
1482
- block.nodes.push(node);
1483
- node.parent = block;
1484
- node.prev = prev;
1485
- prev = node;
1486
- return node;
1487
- };
1488
-
1489
- push({ type: 'bos' });
1490
-
1491
- while (index < length) {
1492
- block = stack[stack.length - 1];
1493
- value = advance();
1494
-
1495
- /**
1496
- * Invalid chars
1497
- */
1498
-
1499
- if (value === CHAR_ZERO_WIDTH_NOBREAK_SPACE || value === CHAR_NO_BREAK_SPACE) {
1500
- continue;
1501
- }
1502
-
1503
- /**
1504
- * Escaped chars
1505
- */
1506
-
1507
- if (value === CHAR_BACKSLASH) {
1508
- push({ type: 'text', value: (options.keepEscaping ? value : '') + advance() });
1509
- continue;
1510
- }
1511
-
1512
- /**
1513
- * Right square bracket (literal): ']'
1514
- */
1515
-
1516
- if (value === CHAR_RIGHT_SQUARE_BRACKET$1) {
1517
- push({ type: 'text', value: '\\' + value });
1518
- continue;
1519
- }
1520
-
1521
- /**
1522
- * Left square bracket: '['
1523
- */
1524
-
1525
- if (value === CHAR_LEFT_SQUARE_BRACKET$1) {
1526
- brackets++;
1527
- let next;
1528
-
1529
- while (index < length && (next = advance())) {
1530
- value += next;
1531
-
1532
- if (next === CHAR_LEFT_SQUARE_BRACKET$1) {
1533
- brackets++;
1534
- continue;
1535
- }
1536
-
1537
- if (next === CHAR_BACKSLASH) {
1538
- value += advance();
1539
- continue;
1540
- }
1541
-
1542
- if (next === CHAR_RIGHT_SQUARE_BRACKET$1) {
1543
- brackets--;
1544
-
1545
- if (brackets === 0) {
1546
- break;
1547
- }
1548
- }
1549
- }
1550
-
1551
- push({ type: 'text', value });
1552
- continue;
1553
- }
1554
-
1555
- /**
1556
- * Parentheses
1557
- */
1558
-
1559
- if (value === CHAR_LEFT_PARENTHESES$1) {
1560
- block = push({ type: 'paren', nodes: [] });
1561
- stack.push(block);
1562
- push({ type: 'text', value });
1563
- continue;
1564
- }
1565
-
1566
- if (value === CHAR_RIGHT_PARENTHESES$1) {
1567
- if (block.type !== 'paren') {
1568
- push({ type: 'text', value });
1569
- continue;
1570
- }
1571
- block = stack.pop();
1572
- push({ type: 'text', value });
1573
- block = stack[stack.length - 1];
1574
- continue;
1575
- }
1576
-
1577
- /**
1578
- * Quotes: '|"|`
1579
- */
1580
-
1581
- if (value === CHAR_DOUBLE_QUOTE || value === CHAR_SINGLE_QUOTE || value === CHAR_BACKTICK) {
1582
- let open = value;
1583
- let next;
1584
-
1585
- if (options.keepQuotes !== true) {
1586
- value = '';
1587
- }
1588
-
1589
- while (index < length && (next = advance())) {
1590
- if (next === CHAR_BACKSLASH) {
1591
- value += next + advance();
1592
- continue;
1593
- }
1594
-
1595
- if (next === open) {
1596
- if (options.keepQuotes === true) value += next;
1597
- break;
1598
- }
1599
-
1600
- value += next;
1601
- }
1602
-
1603
- push({ type: 'text', value });
1604
- continue;
1605
- }
1606
-
1607
- /**
1608
- * Left curly brace: '{'
1609
- */
1610
-
1611
- if (value === CHAR_LEFT_CURLY_BRACE$1) {
1612
- depth++;
1613
-
1614
- let dollar = prev.value && prev.value.slice(-1) === '$' || block.dollar === true;
1615
- let brace = {
1616
- type: 'brace',
1617
- open: true,
1618
- close: false,
1619
- dollar,
1620
- depth,
1621
- commas: 0,
1622
- ranges: 0,
1623
- nodes: []
1624
- };
1625
-
1626
- block = push(brace);
1627
- stack.push(block);
1628
- push({ type: 'open', value });
1629
- continue;
1630
- }
1631
-
1632
- /**
1633
- * Right curly brace: '}'
1634
- */
1635
-
1636
- if (value === CHAR_RIGHT_CURLY_BRACE$1) {
1637
- if (block.type !== 'brace') {
1638
- push({ type: 'text', value });
1639
- continue;
1640
- }
1641
-
1642
- let type = 'close';
1643
- block = stack.pop();
1644
- block.close = true;
1645
-
1646
- push({ type, value });
1647
- depth--;
1648
-
1649
- block = stack[stack.length - 1];
1650
- continue;
1651
- }
1652
-
1653
- /**
1654
- * Comma: ','
1655
- */
1656
-
1657
- if (value === CHAR_COMMA$1 && depth > 0) {
1658
- if (block.ranges > 0) {
1659
- block.ranges = 0;
1660
- let open = block.nodes.shift();
1661
- block.nodes = [open, { type: 'text', value: stringify$1(block) }];
1662
- }
1663
-
1664
- push({ type: 'comma', value });
1665
- block.commas++;
1666
- continue;
1667
- }
1668
-
1669
- /**
1670
- * Dot: '.'
1671
- */
1672
-
1673
- if (value === CHAR_DOT$1 && depth > 0 && block.commas === 0) {
1674
- let siblings = block.nodes;
1675
-
1676
- if (depth === 0 || siblings.length === 0) {
1677
- push({ type: 'text', value });
1678
- continue;
1679
- }
1680
-
1681
- if (prev.type === 'dot') {
1682
- block.range = [];
1683
- prev.value += value;
1684
- prev.type = 'range';
1685
-
1686
- if (block.nodes.length !== 3 && block.nodes.length !== 5) {
1687
- block.invalid = true;
1688
- block.ranges = 0;
1689
- prev.type = 'text';
1690
- continue;
1691
- }
1692
-
1693
- block.ranges++;
1694
- block.args = [];
1695
- continue;
1696
- }
1697
-
1698
- if (prev.type === 'range') {
1699
- siblings.pop();
1700
-
1701
- let before = siblings[siblings.length - 1];
1702
- before.value += prev.value + value;
1703
- prev = before;
1704
- block.ranges--;
1705
- continue;
1706
- }
1707
-
1708
- push({ type: 'dot', value });
1709
- continue;
1710
- }
1711
-
1712
- /**
1713
- * Text
1714
- */
1715
-
1716
- push({ type: 'text', value });
1717
- }
1718
-
1719
- // Mark imbalanced braces and brackets as invalid
1720
- do {
1721
- block = stack.pop();
1722
-
1723
- if (block.type !== 'root') {
1724
- block.nodes.forEach(node => {
1725
- if (!node.nodes) {
1726
- if (node.type === 'open') node.isOpen = true;
1727
- if (node.type === 'close') node.isClose = true;
1728
- if (!node.nodes) node.type = 'text';
1729
- node.invalid = true;
1730
- }
1731
- });
1732
-
1733
- // get the location of the block on parent.nodes (block's siblings)
1734
- let parent = stack[stack.length - 1];
1735
- let index = parent.nodes.indexOf(block);
1736
- // replace the (invalid) block with it's nodes
1737
- parent.nodes.splice(index, 1, ...block.nodes);
1738
- }
1739
- } while (stack.length > 0);
1740
-
1741
- push({ type: 'eos' });
1742
- return ast;
1743
- };
1744
-
1745
- var parse_1$1 = parse$3;
1746
-
1747
- const stringify = stringify$4;
1748
- const compile = compile_1;
1749
- const expand = expand_1;
1750
- const parse$2 = parse_1$1;
1751
-
1752
- /**
1753
- * Expand the given pattern or create a regex-compatible string.
1754
- *
1755
- * ```js
1756
- * const braces = require('braces');
1757
- * console.log(braces('{a,b,c}', { compile: true })); //=> ['(a|b|c)']
1758
- * console.log(braces('{a,b,c}')); //=> ['a', 'b', 'c']
1759
- * ```
1760
- * @param {String} `str`
1761
- * @param {Object} `options`
1762
- * @return {String}
1763
- * @api public
1764
- */
1765
-
1766
- const braces$1 = (input, options = {}) => {
1767
- let output = [];
1768
-
1769
- if (Array.isArray(input)) {
1770
- for (let pattern of input) {
1771
- let result = braces$1.create(pattern, options);
1772
- if (Array.isArray(result)) {
1773
- output.push(...result);
1774
- } else {
1775
- output.push(result);
1776
- }
1777
- }
1778
- } else {
1779
- output = [].concat(braces$1.create(input, options));
1780
- }
1781
-
1782
- if (options && options.expand === true && options.nodupes === true) {
1783
- output = [...new Set(output)];
1784
- }
1785
- return output;
1786
- };
1787
-
1788
- /**
1789
- * Parse the given `str` with the given `options`.
1790
- *
1791
- * ```js
1792
- * // braces.parse(pattern, [, options]);
1793
- * const ast = braces.parse('a/{b,c}/d');
1794
- * console.log(ast);
1795
- * ```
1796
- * @param {String} pattern Brace pattern to parse
1797
- * @param {Object} options
1798
- * @return {Object} Returns an AST
1799
- * @api public
1800
- */
1801
-
1802
- braces$1.parse = (input, options = {}) => parse$2(input, options);
1803
-
1804
- /**
1805
- * Creates a braces string from an AST, or an AST node.
1806
- *
1807
- * ```js
1808
- * const braces = require('braces');
1809
- * let ast = braces.parse('foo/{a,b}/bar');
1810
- * console.log(stringify(ast.nodes[2])); //=> '{a,b}'
1811
- * ```
1812
- * @param {String} `input` Brace pattern or AST.
1813
- * @param {Object} `options`
1814
- * @return {Array} Returns an array of expanded values.
1815
- * @api public
1816
- */
1817
-
1818
- braces$1.stringify = (input, options = {}) => {
1819
- if (typeof input === 'string') {
1820
- return stringify(braces$1.parse(input, options), options);
1821
- }
1822
- return stringify(input, options);
1823
- };
1824
-
1825
- /**
1826
- * Compiles a brace pattern into a regex-compatible, optimized string.
1827
- * This method is called by the main [braces](#braces) function by default.
1828
- *
1829
- * ```js
1830
- * const braces = require('braces');
1831
- * console.log(braces.compile('a/{b,c}/d'));
1832
- * //=> ['a/(b|c)/d']
1833
- * ```
1834
- * @param {String} `input` Brace pattern or AST.
1835
- * @param {Object} `options`
1836
- * @return {Array} Returns an array of expanded values.
1837
- * @api public
1838
- */
1839
-
1840
- braces$1.compile = (input, options = {}) => {
1841
- if (typeof input === 'string') {
1842
- input = braces$1.parse(input, options);
1843
- }
1844
- return compile(input, options);
1845
- };
1846
-
1847
- /**
1848
- * Expands a brace pattern into an array. This method is called by the
1849
- * main [braces](#braces) function when `options.expand` is true. Before
1850
- * using this method it's recommended that you read the [performance notes](#performance))
1851
- * and advantages of using [.compile](#compile) instead.
1852
- *
1853
- * ```js
1854
- * const braces = require('braces');
1855
- * console.log(braces.expand('a/{b,c}/d'));
1856
- * //=> ['a/b/d', 'a/c/d'];
1857
- * ```
1858
- * @param {String} `pattern` Brace pattern
1859
- * @param {Object} `options`
1860
- * @return {Array} Returns an array of expanded values.
1861
- * @api public
1862
- */
1863
-
1864
- braces$1.expand = (input, options = {}) => {
1865
- if (typeof input === 'string') {
1866
- input = braces$1.parse(input, options);
1867
- }
1868
-
1869
- let result = expand(input, options);
1870
-
1871
- // filter out empty strings if specified
1872
- if (options.noempty === true) {
1873
- result = result.filter(Boolean);
1874
- }
1875
-
1876
- // filter out duplicates if specified
1877
- if (options.nodupes === true) {
1878
- result = [...new Set(result)];
1879
- }
1880
-
1881
- return result;
1882
- };
1883
-
1884
- /**
1885
- * Processes a brace pattern and returns either an expanded array
1886
- * (if `options.expand` is true), a highly optimized regex-compatible string.
1887
- * This method is called by the main [braces](#braces) function.
1888
- *
1889
- * ```js
1890
- * const braces = require('braces');
1891
- * console.log(braces.create('user-{200..300}/project-{a,b,c}-{1..10}'))
1892
- * //=> 'user-(20[0-9]|2[1-9][0-9]|300)/project-(a|b|c)-([1-9]|10)'
1893
- * ```
1894
- * @param {String} `pattern` Brace pattern
1895
- * @param {Object} `options`
1896
- * @return {Array} Returns an array of expanded values.
1897
- * @api public
1898
- */
1899
-
1900
- braces$1.create = (input, options = {}) => {
1901
- if (input === '' || input.length < 3) {
1902
- return [input];
1903
- }
1904
-
1905
- return options.expand !== true
1906
- ? braces$1.compile(input, options)
1907
- : braces$1.expand(input, options);
1908
- };
1909
-
1910
- /**
1911
- * Expose "braces"
1912
- */
1913
-
1914
- var braces_1 = braces$1;
1915
-
1916
- var picomatch$2 = {exports: {}};
1917
-
1918
- var utils$f = {};
1919
-
1920
- const path$7 = k;
1921
- const WIN_SLASH = '\\\\/';
1922
- const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
1923
-
1924
- /**
1925
- * Posix glob regex
1926
- */
1927
-
1928
- const DOT_LITERAL = '\\.';
1929
- const PLUS_LITERAL = '\\+';
1930
- const QMARK_LITERAL = '\\?';
1931
- const SLASH_LITERAL = '\\/';
1932
- const ONE_CHAR = '(?=.)';
1933
- const QMARK = '[^/]';
1934
- const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
1935
- const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
1936
- const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
1937
- const NO_DOT = `(?!${DOT_LITERAL})`;
1938
- const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
1939
- const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
1940
- const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
1941
- const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
1942
- const STAR = `${QMARK}*?`;
1943
-
1944
- const POSIX_CHARS = {
1945
- DOT_LITERAL,
1946
- PLUS_LITERAL,
1947
- QMARK_LITERAL,
1948
- SLASH_LITERAL,
1949
- ONE_CHAR,
1950
- QMARK,
1951
- END_ANCHOR,
1952
- DOTS_SLASH,
1953
- NO_DOT,
1954
- NO_DOTS,
1955
- NO_DOT_SLASH,
1956
- NO_DOTS_SLASH,
1957
- QMARK_NO_DOT,
1958
- STAR,
1959
- START_ANCHOR
1960
- };
1961
-
1962
- /**
1963
- * Windows glob regex
1964
- */
1965
-
1966
- const WINDOWS_CHARS = {
1967
- ...POSIX_CHARS,
1968
-
1969
- SLASH_LITERAL: `[${WIN_SLASH}]`,
1970
- QMARK: WIN_NO_SLASH,
1971
- STAR: `${WIN_NO_SLASH}*?`,
1972
- DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
1973
- NO_DOT: `(?!${DOT_LITERAL})`,
1974
- NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1975
- NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
1976
- NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
1977
- QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
1978
- START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
1979
- END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
1980
- };
1981
-
1982
- /**
1983
- * POSIX Bracket Regex
1984
- */
1985
-
1986
- const POSIX_REGEX_SOURCE$1 = {
1987
- alnum: 'a-zA-Z0-9',
1988
- alpha: 'a-zA-Z',
1989
- ascii: '\\x00-\\x7F',
1990
- blank: ' \\t',
1991
- cntrl: '\\x00-\\x1F\\x7F',
1992
- digit: '0-9',
1993
- graph: '\\x21-\\x7E',
1994
- lower: 'a-z',
1995
- print: '\\x20-\\x7E ',
1996
- punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
1997
- space: ' \\t\\r\\n\\v\\f',
1998
- upper: 'A-Z',
1999
- word: 'A-Za-z0-9_',
2000
- xdigit: 'A-Fa-f0-9'
2001
- };
2002
-
2003
- var constants$3 = {
2004
- MAX_LENGTH: 1024 * 64,
2005
- POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
2006
-
2007
- // regular expressions
2008
- REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
2009
- REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
2010
- REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
2011
- REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
2012
- REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
2013
- REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
2014
-
2015
- // Replace globs with equivalent patterns to reduce parsing time.
2016
- REPLACEMENTS: {
2017
- '***': '*',
2018
- '**/**': '**',
2019
- '**/**/**': '**'
2020
- },
2021
-
2022
- // Digits
2023
- CHAR_0: 48, /* 0 */
2024
- CHAR_9: 57, /* 9 */
2025
-
2026
- // Alphabet chars.
2027
- CHAR_UPPERCASE_A: 65, /* A */
2028
- CHAR_LOWERCASE_A: 97, /* a */
2029
- CHAR_UPPERCASE_Z: 90, /* Z */
2030
- CHAR_LOWERCASE_Z: 122, /* z */
2031
-
2032
- CHAR_LEFT_PARENTHESES: 40, /* ( */
2033
- CHAR_RIGHT_PARENTHESES: 41, /* ) */
2034
-
2035
- CHAR_ASTERISK: 42, /* * */
2036
-
2037
- // Non-alphabetic chars.
2038
- CHAR_AMPERSAND: 38, /* & */
2039
- CHAR_AT: 64, /* @ */
2040
- CHAR_BACKWARD_SLASH: 92, /* \ */
2041
- CHAR_CARRIAGE_RETURN: 13, /* \r */
2042
- CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
2043
- CHAR_COLON: 58, /* : */
2044
- CHAR_COMMA: 44, /* , */
2045
- CHAR_DOT: 46, /* . */
2046
- CHAR_DOUBLE_QUOTE: 34, /* " */
2047
- CHAR_EQUAL: 61, /* = */
2048
- CHAR_EXCLAMATION_MARK: 33, /* ! */
2049
- CHAR_FORM_FEED: 12, /* \f */
2050
- CHAR_FORWARD_SLASH: 47, /* / */
2051
- CHAR_GRAVE_ACCENT: 96, /* ` */
2052
- CHAR_HASH: 35, /* # */
2053
- CHAR_HYPHEN_MINUS: 45, /* - */
2054
- CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
2055
- CHAR_LEFT_CURLY_BRACE: 123, /* { */
2056
- CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
2057
- CHAR_LINE_FEED: 10, /* \n */
2058
- CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
2059
- CHAR_PERCENT: 37, /* % */
2060
- CHAR_PLUS: 43, /* + */
2061
- CHAR_QUESTION_MARK: 63, /* ? */
2062
- CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
2063
- CHAR_RIGHT_CURLY_BRACE: 125, /* } */
2064
- CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
2065
- CHAR_SEMICOLON: 59, /* ; */
2066
- CHAR_SINGLE_QUOTE: 39, /* ' */
2067
- CHAR_SPACE: 32, /* */
2068
- CHAR_TAB: 9, /* \t */
2069
- CHAR_UNDERSCORE: 95, /* _ */
2070
- CHAR_VERTICAL_LINE: 124, /* | */
2071
- CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
2072
-
2073
- SEP: path$7.sep,
2074
-
2075
- /**
2076
- * Create EXTGLOB_CHARS
2077
- */
2078
-
2079
- extglobChars(chars) {
2080
- return {
2081
- '!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
2082
- '?': { type: 'qmark', open: '(?:', close: ')?' },
2083
- '+': { type: 'plus', open: '(?:', close: ')+' },
2084
- '*': { type: 'star', open: '(?:', close: ')*' },
2085
- '@': { type: 'at', open: '(?:', close: ')' }
2086
- };
2087
- },
2088
-
2089
- /**
2090
- * Create GLOB_CHARS
2091
- */
2092
-
2093
- globChars(win32) {
2094
- return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
2095
- }
2096
- };
2097
-
2098
- (function (exports) {
2099
-
2100
- const path = k;
2101
- const win32 = process.platform === 'win32';
2102
- const {
2103
- REGEX_BACKSLASH,
2104
- REGEX_REMOVE_BACKSLASH,
2105
- REGEX_SPECIAL_CHARS,
2106
- REGEX_SPECIAL_CHARS_GLOBAL
2107
- } = constants$3;
2108
-
2109
- exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
2110
- exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
2111
- exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
2112
- exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
2113
- exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
2114
-
2115
- exports.removeBackslashes = str => {
2116
- return str.replace(REGEX_REMOVE_BACKSLASH, match => {
2117
- return match === '\\' ? '' : match;
2118
- });
2119
- };
2120
-
2121
- exports.supportsLookbehinds = () => {
2122
- const segs = process.version.slice(1).split('.').map(Number);
2123
- if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
2124
- return true;
2125
- }
2126
- return false;
2127
- };
2128
-
2129
- exports.isWindows = options => {
2130
- if (options && typeof options.windows === 'boolean') {
2131
- return options.windows;
2132
- }
2133
- return win32 === true || path.sep === '\\';
2134
- };
2135
-
2136
- exports.escapeLast = (input, char, lastIdx) => {
2137
- const idx = input.lastIndexOf(char, lastIdx);
2138
- if (idx === -1) return input;
2139
- if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
2140
- return `${input.slice(0, idx)}\\${input.slice(idx)}`;
2141
- };
2142
-
2143
- exports.removePrefix = (input, state = {}) => {
2144
- let output = input;
2145
- if (output.startsWith('./')) {
2146
- output = output.slice(2);
2147
- state.prefix = './';
2148
- }
2149
- return output;
2150
- };
2151
-
2152
- exports.wrapOutput = (input, state = {}, options = {}) => {
2153
- const prepend = options.contains ? '' : '^';
2154
- const append = options.contains ? '' : '$';
2155
-
2156
- let output = `${prepend}(?:${input})${append}`;
2157
- if (state.negated === true) {
2158
- output = `(?:^(?!${output}).*$)`;
2159
- }
2160
- return output;
2161
- };
2162
- } (utils$f));
2163
-
2164
- const utils$e = utils$f;
2165
- const {
2166
- CHAR_ASTERISK, /* * */
2167
- CHAR_AT, /* @ */
2168
- CHAR_BACKWARD_SLASH, /* \ */
2169
- CHAR_COMMA, /* , */
2170
- CHAR_DOT, /* . */
2171
- CHAR_EXCLAMATION_MARK, /* ! */
2172
- CHAR_FORWARD_SLASH, /* / */
2173
- CHAR_LEFT_CURLY_BRACE, /* { */
2174
- CHAR_LEFT_PARENTHESES, /* ( */
2175
- CHAR_LEFT_SQUARE_BRACKET, /* [ */
2176
- CHAR_PLUS, /* + */
2177
- CHAR_QUESTION_MARK, /* ? */
2178
- CHAR_RIGHT_CURLY_BRACE, /* } */
2179
- CHAR_RIGHT_PARENTHESES, /* ) */
2180
- CHAR_RIGHT_SQUARE_BRACKET /* ] */
2181
- } = constants$3;
2182
-
2183
- const isPathSeparator = code => {
2184
- return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
2185
- };
2186
-
2187
- const depth = token => {
2188
- if (token.isPrefix !== true) {
2189
- token.depth = token.isGlobstar ? Infinity : 1;
2190
- }
2191
- };
2192
-
2193
- /**
2194
- * Quickly scans a glob pattern and returns an object with a handful of
2195
- * useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
2196
- * `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
2197
- * with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
2198
- *
2199
- * ```js
2200
- * const pm = require('picomatch');
2201
- * console.log(pm.scan('foo/bar/*.js'));
2202
- * { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
2203
- * ```
2204
- * @param {String} `str`
2205
- * @param {Object} `options`
2206
- * @return {Object} Returns an object with tokens and regex source string.
2207
- * @api public
2208
- */
2209
-
2210
- const scan$1 = (input, options) => {
2211
- const opts = options || {};
2212
-
2213
- const length = input.length - 1;
2214
- const scanToEnd = opts.parts === true || opts.scanToEnd === true;
2215
- const slashes = [];
2216
- const tokens = [];
2217
- const parts = [];
2218
-
2219
- let str = input;
2220
- let index = -1;
2221
- let start = 0;
2222
- let lastIndex = 0;
2223
- let isBrace = false;
2224
- let isBracket = false;
2225
- let isGlob = false;
2226
- let isExtglob = false;
2227
- let isGlobstar = false;
2228
- let braceEscaped = false;
2229
- let backslashes = false;
2230
- let negated = false;
2231
- let negatedExtglob = false;
2232
- let finished = false;
2233
- let braces = 0;
2234
- let prev;
2235
- let code;
2236
- let token = { value: '', depth: 0, isGlob: false };
2237
-
2238
- const eos = () => index >= length;
2239
- const peek = () => str.charCodeAt(index + 1);
2240
- const advance = () => {
2241
- prev = code;
2242
- return str.charCodeAt(++index);
2243
- };
2244
-
2245
- while (index < length) {
2246
- code = advance();
2247
- let next;
2248
-
2249
- if (code === CHAR_BACKWARD_SLASH) {
2250
- backslashes = token.backslashes = true;
2251
- code = advance();
2252
-
2253
- if (code === CHAR_LEFT_CURLY_BRACE) {
2254
- braceEscaped = true;
2255
- }
2256
- continue;
2257
- }
2258
-
2259
- if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
2260
- braces++;
2261
-
2262
- while (eos() !== true && (code = advance())) {
2263
- if (code === CHAR_BACKWARD_SLASH) {
2264
- backslashes = token.backslashes = true;
2265
- advance();
2266
- continue;
2267
- }
2268
-
2269
- if (code === CHAR_LEFT_CURLY_BRACE) {
2270
- braces++;
2271
- continue;
2272
- }
2273
-
2274
- if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
2275
- isBrace = token.isBrace = true;
2276
- isGlob = token.isGlob = true;
2277
- finished = true;
2278
-
2279
- if (scanToEnd === true) {
2280
- continue;
2281
- }
2282
-
2283
- break;
2284
- }
2285
-
2286
- if (braceEscaped !== true && code === CHAR_COMMA) {
2287
- isBrace = token.isBrace = true;
2288
- isGlob = token.isGlob = true;
2289
- finished = true;
2290
-
2291
- if (scanToEnd === true) {
2292
- continue;
2293
- }
2294
-
2295
- break;
2296
- }
2297
-
2298
- if (code === CHAR_RIGHT_CURLY_BRACE) {
2299
- braces--;
2300
-
2301
- if (braces === 0) {
2302
- braceEscaped = false;
2303
- isBrace = token.isBrace = true;
2304
- finished = true;
2305
- break;
2306
- }
2307
- }
2308
- }
2309
-
2310
- if (scanToEnd === true) {
2311
- continue;
2312
- }
2313
-
2314
- break;
2315
- }
2316
-
2317
- if (code === CHAR_FORWARD_SLASH) {
2318
- slashes.push(index);
2319
- tokens.push(token);
2320
- token = { value: '', depth: 0, isGlob: false };
2321
-
2322
- if (finished === true) continue;
2323
- if (prev === CHAR_DOT && index === (start + 1)) {
2324
- start += 2;
2325
- continue;
2326
- }
2327
-
2328
- lastIndex = index + 1;
2329
- continue;
2330
- }
2331
-
2332
- if (opts.noext !== true) {
2333
- const isExtglobChar = code === CHAR_PLUS
2334
- || code === CHAR_AT
2335
- || code === CHAR_ASTERISK
2336
- || code === CHAR_QUESTION_MARK
2337
- || code === CHAR_EXCLAMATION_MARK;
2338
-
2339
- if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
2340
- isGlob = token.isGlob = true;
2341
- isExtglob = token.isExtglob = true;
2342
- finished = true;
2343
- if (code === CHAR_EXCLAMATION_MARK && index === start) {
2344
- negatedExtglob = true;
2345
- }
2346
-
2347
- if (scanToEnd === true) {
2348
- while (eos() !== true && (code = advance())) {
2349
- if (code === CHAR_BACKWARD_SLASH) {
2350
- backslashes = token.backslashes = true;
2351
- code = advance();
2352
- continue;
2353
- }
2354
-
2355
- if (code === CHAR_RIGHT_PARENTHESES) {
2356
- isGlob = token.isGlob = true;
2357
- finished = true;
2358
- break;
2359
- }
2360
- }
2361
- continue;
2362
- }
2363
- break;
2364
- }
2365
- }
2366
-
2367
- if (code === CHAR_ASTERISK) {
2368
- if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
2369
- isGlob = token.isGlob = true;
2370
- finished = true;
2371
-
2372
- if (scanToEnd === true) {
2373
- continue;
2374
- }
2375
- break;
2376
- }
2377
-
2378
- if (code === CHAR_QUESTION_MARK) {
2379
- isGlob = token.isGlob = true;
2380
- finished = true;
2381
-
2382
- if (scanToEnd === true) {
2383
- continue;
2384
- }
2385
- break;
2386
- }
2387
-
2388
- if (code === CHAR_LEFT_SQUARE_BRACKET) {
2389
- while (eos() !== true && (next = advance())) {
2390
- if (next === CHAR_BACKWARD_SLASH) {
2391
- backslashes = token.backslashes = true;
2392
- advance();
2393
- continue;
2394
- }
2395
-
2396
- if (next === CHAR_RIGHT_SQUARE_BRACKET) {
2397
- isBracket = token.isBracket = true;
2398
- isGlob = token.isGlob = true;
2399
- finished = true;
2400
- break;
2401
- }
2402
- }
2403
-
2404
- if (scanToEnd === true) {
2405
- continue;
2406
- }
2407
-
2408
- break;
2409
- }
2410
-
2411
- if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
2412
- negated = token.negated = true;
2413
- start++;
2414
- continue;
2415
- }
2416
-
2417
- if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
2418
- isGlob = token.isGlob = true;
2419
-
2420
- if (scanToEnd === true) {
2421
- while (eos() !== true && (code = advance())) {
2422
- if (code === CHAR_LEFT_PARENTHESES) {
2423
- backslashes = token.backslashes = true;
2424
- code = advance();
2425
- continue;
2426
- }
2427
-
2428
- if (code === CHAR_RIGHT_PARENTHESES) {
2429
- finished = true;
2430
- break;
2431
- }
2432
- }
2433
- continue;
2434
- }
2435
- break;
2436
- }
2437
-
2438
- if (isGlob === true) {
2439
- finished = true;
2440
-
2441
- if (scanToEnd === true) {
2442
- continue;
2443
- }
2444
-
2445
- break;
2446
- }
2447
- }
2448
-
2449
- if (opts.noext === true) {
2450
- isExtglob = false;
2451
- isGlob = false;
2452
- }
2453
-
2454
- let base = str;
2455
- let prefix = '';
2456
- let glob = '';
2457
-
2458
- if (start > 0) {
2459
- prefix = str.slice(0, start);
2460
- str = str.slice(start);
2461
- lastIndex -= start;
2462
- }
2463
-
2464
- if (base && isGlob === true && lastIndex > 0) {
2465
- base = str.slice(0, lastIndex);
2466
- glob = str.slice(lastIndex);
2467
- } else if (isGlob === true) {
2468
- base = '';
2469
- glob = str;
2470
- } else {
2471
- base = str;
2472
- }
2473
-
2474
- if (base && base !== '' && base !== '/' && base !== str) {
2475
- if (isPathSeparator(base.charCodeAt(base.length - 1))) {
2476
- base = base.slice(0, -1);
2477
- }
2478
- }
2479
-
2480
- if (opts.unescape === true) {
2481
- if (glob) glob = utils$e.removeBackslashes(glob);
2482
-
2483
- if (base && backslashes === true) {
2484
- base = utils$e.removeBackslashes(base);
2485
- }
2486
- }
2487
-
2488
- const state = {
2489
- prefix,
2490
- input,
2491
- start,
2492
- base,
2493
- glob,
2494
- isBrace,
2495
- isBracket,
2496
- isGlob,
2497
- isExtglob,
2498
- isGlobstar,
2499
- negated,
2500
- negatedExtglob
2501
- };
2502
-
2503
- if (opts.tokens === true) {
2504
- state.maxDepth = 0;
2505
- if (!isPathSeparator(code)) {
2506
- tokens.push(token);
2507
- }
2508
- state.tokens = tokens;
2509
- }
2510
-
2511
- if (opts.parts === true || opts.tokens === true) {
2512
- let prevIndex;
2513
-
2514
- for (let idx = 0; idx < slashes.length; idx++) {
2515
- const n = prevIndex ? prevIndex + 1 : start;
2516
- const i = slashes[idx];
2517
- const value = input.slice(n, i);
2518
- if (opts.tokens) {
2519
- if (idx === 0 && start !== 0) {
2520
- tokens[idx].isPrefix = true;
2521
- tokens[idx].value = prefix;
2522
- } else {
2523
- tokens[idx].value = value;
2524
- }
2525
- depth(tokens[idx]);
2526
- state.maxDepth += tokens[idx].depth;
2527
- }
2528
- if (idx !== 0 || value !== '') {
2529
- parts.push(value);
2530
- }
2531
- prevIndex = i;
2532
- }
2533
-
2534
- if (prevIndex && prevIndex + 1 < input.length) {
2535
- const value = input.slice(prevIndex + 1);
2536
- parts.push(value);
2537
-
2538
- if (opts.tokens) {
2539
- tokens[tokens.length - 1].value = value;
2540
- depth(tokens[tokens.length - 1]);
2541
- state.maxDepth += tokens[tokens.length - 1].depth;
2542
- }
2543
- }
2544
-
2545
- state.slashes = slashes;
2546
- state.parts = parts;
2547
- }
2548
-
2549
- return state;
2550
- };
2551
-
2552
- var scan_1 = scan$1;
2553
-
2554
- const constants$2 = constants$3;
2555
- const utils$d = utils$f;
2556
-
2557
- /**
2558
- * Constants
2559
- */
2560
-
2561
- const {
2562
- MAX_LENGTH,
2563
- POSIX_REGEX_SOURCE,
2564
- REGEX_NON_SPECIAL_CHARS,
2565
- REGEX_SPECIAL_CHARS_BACKREF,
2566
- REPLACEMENTS
2567
- } = constants$2;
2568
-
2569
- /**
2570
- * Helpers
2571
- */
2572
-
2573
- const expandRange = (args, options) => {
2574
- if (typeof options.expandRange === 'function') {
2575
- return options.expandRange(...args, options);
2576
- }
2577
-
2578
- args.sort();
2579
- const value = `[${args.join('-')}]`;
2580
-
2581
- try {
2582
- /* eslint-disable-next-line no-new */
2583
- new RegExp(value);
2584
- } catch (ex) {
2585
- return args.map(v => utils$d.escapeRegex(v)).join('..');
2586
- }
2587
-
2588
- return value;
2589
- };
2590
-
2591
- /**
2592
- * Create the message for a syntax error
2593
- */
2594
-
2595
- const syntaxError = (type, char) => {
2596
- return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
2597
- };
2598
-
2599
- /**
2600
- * Parse the given input string.
2601
- * @param {String} input
2602
- * @param {Object} options
2603
- * @return {Object}
2604
- */
2605
-
2606
- const parse$1 = (input, options) => {
2607
- if (typeof input !== 'string') {
2608
- throw new TypeError('Expected a string');
2609
- }
2610
-
2611
- input = REPLACEMENTS[input] || input;
2612
-
2613
- const opts = { ...options };
2614
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
2615
-
2616
- let len = input.length;
2617
- if (len > max) {
2618
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
2619
- }
2620
-
2621
- const bos = { type: 'bos', value: '', output: opts.prepend || '' };
2622
- const tokens = [bos];
2623
-
2624
- const capture = opts.capture ? '' : '?:';
2625
- const win32 = utils$d.isWindows(options);
2626
-
2627
- // create constants based on platform, for windows or posix
2628
- const PLATFORM_CHARS = constants$2.globChars(win32);
2629
- const EXTGLOB_CHARS = constants$2.extglobChars(PLATFORM_CHARS);
2630
-
2631
- const {
2632
- DOT_LITERAL,
2633
- PLUS_LITERAL,
2634
- SLASH_LITERAL,
2635
- ONE_CHAR,
2636
- DOTS_SLASH,
2637
- NO_DOT,
2638
- NO_DOT_SLASH,
2639
- NO_DOTS_SLASH,
2640
- QMARK,
2641
- QMARK_NO_DOT,
2642
- STAR,
2643
- START_ANCHOR
2644
- } = PLATFORM_CHARS;
2645
-
2646
- const globstar = opts => {
2647
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
2648
- };
2649
-
2650
- const nodot = opts.dot ? '' : NO_DOT;
2651
- const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
2652
- let star = opts.bash === true ? globstar(opts) : STAR;
2653
-
2654
- if (opts.capture) {
2655
- star = `(${star})`;
2656
- }
2657
-
2658
- // minimatch options support
2659
- if (typeof opts.noext === 'boolean') {
2660
- opts.noextglob = opts.noext;
2661
- }
2662
-
2663
- const state = {
2664
- input,
2665
- index: -1,
2666
- start: 0,
2667
- dot: opts.dot === true,
2668
- consumed: '',
2669
- output: '',
2670
- prefix: '',
2671
- backtrack: false,
2672
- negated: false,
2673
- brackets: 0,
2674
- braces: 0,
2675
- parens: 0,
2676
- quotes: 0,
2677
- globstar: false,
2678
- tokens
2679
- };
2680
-
2681
- input = utils$d.removePrefix(input, state);
2682
- len = input.length;
2683
-
2684
- const extglobs = [];
2685
- const braces = [];
2686
- const stack = [];
2687
- let prev = bos;
2688
- let value;
2689
-
2690
- /**
2691
- * Tokenizing helpers
2692
- */
2693
-
2694
- const eos = () => state.index === len - 1;
2695
- const peek = state.peek = (n = 1) => input[state.index + n];
2696
- const advance = state.advance = () => input[++state.index] || '';
2697
- const remaining = () => input.slice(state.index + 1);
2698
- const consume = (value = '', num = 0) => {
2699
- state.consumed += value;
2700
- state.index += num;
2701
- };
2702
-
2703
- const append = token => {
2704
- state.output += token.output != null ? token.output : token.value;
2705
- consume(token.value);
2706
- };
2707
-
2708
- const negate = () => {
2709
- let count = 1;
2710
-
2711
- while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
2712
- advance();
2713
- state.start++;
2714
- count++;
2715
- }
2716
-
2717
- if (count % 2 === 0) {
2718
- return false;
2719
- }
2720
-
2721
- state.negated = true;
2722
- state.start++;
2723
- return true;
2724
- };
2725
-
2726
- const increment = type => {
2727
- state[type]++;
2728
- stack.push(type);
2729
- };
2730
-
2731
- const decrement = type => {
2732
- state[type]--;
2733
- stack.pop();
2734
- };
2735
-
2736
- /**
2737
- * Push tokens onto the tokens array. This helper speeds up
2738
- * tokenizing by 1) helping us avoid backtracking as much as possible,
2739
- * and 2) helping us avoid creating extra tokens when consecutive
2740
- * characters are plain text. This improves performance and simplifies
2741
- * lookbehinds.
2742
- */
2743
-
2744
- const push = tok => {
2745
- if (prev.type === 'globstar') {
2746
- const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
2747
- const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
2748
-
2749
- if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
2750
- state.output = state.output.slice(0, -prev.output.length);
2751
- prev.type = 'star';
2752
- prev.value = '*';
2753
- prev.output = star;
2754
- state.output += prev.output;
2755
- }
2756
- }
2757
-
2758
- if (extglobs.length && tok.type !== 'paren') {
2759
- extglobs[extglobs.length - 1].inner += tok.value;
2760
- }
2761
-
2762
- if (tok.value || tok.output) append(tok);
2763
- if (prev && prev.type === 'text' && tok.type === 'text') {
2764
- prev.value += tok.value;
2765
- prev.output = (prev.output || '') + tok.value;
2766
- return;
2767
- }
2768
-
2769
- tok.prev = prev;
2770
- tokens.push(tok);
2771
- prev = tok;
2772
- };
2773
-
2774
- const extglobOpen = (type, value) => {
2775
- const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
2776
-
2777
- token.prev = prev;
2778
- token.parens = state.parens;
2779
- token.output = state.output;
2780
- const output = (opts.capture ? '(' : '') + token.open;
2781
-
2782
- increment('parens');
2783
- push({ type, value, output: state.output ? '' : ONE_CHAR });
2784
- push({ type: 'paren', extglob: true, value: advance(), output });
2785
- extglobs.push(token);
2786
- };
2787
-
2788
- const extglobClose = token => {
2789
- let output = token.close + (opts.capture ? ')' : '');
2790
- let rest;
2791
-
2792
- if (token.type === 'negate') {
2793
- let extglobStar = star;
2794
-
2795
- if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
2796
- extglobStar = globstar(opts);
2797
- }
2798
-
2799
- if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
2800
- output = token.close = `)$))${extglobStar}`;
2801
- }
2802
-
2803
- if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
2804
- // Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
2805
- // In this case, we need to parse the string and use it in the output of the original pattern.
2806
- // Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
2807
- //
2808
- // Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
2809
- const expression = parse$1(rest, { ...options, fastpaths: false }).output;
2810
-
2811
- output = token.close = `)${expression})${extglobStar})`;
2812
- }
2813
-
2814
- if (token.prev.type === 'bos') {
2815
- state.negatedExtglob = true;
2816
- }
2817
- }
2818
-
2819
- push({ type: 'paren', extglob: true, value, output });
2820
- decrement('parens');
2821
- };
2822
-
2823
- /**
2824
- * Fast paths
2825
- */
2826
-
2827
- if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
2828
- let backslashes = false;
2829
-
2830
- let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
2831
- if (first === '\\') {
2832
- backslashes = true;
2833
- return m;
2834
- }
2835
-
2836
- if (first === '?') {
2837
- if (esc) {
2838
- return esc + first + (rest ? QMARK.repeat(rest.length) : '');
2839
- }
2840
- if (index === 0) {
2841
- return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
2842
- }
2843
- return QMARK.repeat(chars.length);
2844
- }
2845
-
2846
- if (first === '.') {
2847
- return DOT_LITERAL.repeat(chars.length);
2848
- }
2849
-
2850
- if (first === '*') {
2851
- if (esc) {
2852
- return esc + first + (rest ? star : '');
2853
- }
2854
- return star;
2855
- }
2856
- return esc ? m : `\\${m}`;
2857
- });
2858
-
2859
- if (backslashes === true) {
2860
- if (opts.unescape === true) {
2861
- output = output.replace(/\\/g, '');
2862
- } else {
2863
- output = output.replace(/\\+/g, m => {
2864
- return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
2865
- });
2866
- }
2867
- }
2868
-
2869
- if (output === input && opts.contains === true) {
2870
- state.output = input;
2871
- return state;
2872
- }
2873
-
2874
- state.output = utils$d.wrapOutput(output, state, options);
2875
- return state;
2876
- }
2877
-
2878
- /**
2879
- * Tokenize input until we reach end-of-string
2880
- */
2881
-
2882
- while (!eos()) {
2883
- value = advance();
2884
-
2885
- if (value === '\u0000') {
2886
- continue;
2887
- }
2888
-
2889
- /**
2890
- * Escaped characters
2891
- */
2892
-
2893
- if (value === '\\') {
2894
- const next = peek();
2895
-
2896
- if (next === '/' && opts.bash !== true) {
2897
- continue;
2898
- }
2899
-
2900
- if (next === '.' || next === ';') {
2901
- continue;
2902
- }
2903
-
2904
- if (!next) {
2905
- value += '\\';
2906
- push({ type: 'text', value });
2907
- continue;
2908
- }
2909
-
2910
- // collapse slashes to reduce potential for exploits
2911
- const match = /^\\+/.exec(remaining());
2912
- let slashes = 0;
2913
-
2914
- if (match && match[0].length > 2) {
2915
- slashes = match[0].length;
2916
- state.index += slashes;
2917
- if (slashes % 2 !== 0) {
2918
- value += '\\';
2919
- }
2920
- }
2921
-
2922
- if (opts.unescape === true) {
2923
- value = advance();
2924
- } else {
2925
- value += advance();
2926
- }
2927
-
2928
- if (state.brackets === 0) {
2929
- push({ type: 'text', value });
2930
- continue;
2931
- }
2932
- }
2933
-
2934
- /**
2935
- * If we're inside a regex character class, continue
2936
- * until we reach the closing bracket.
2937
- */
2938
-
2939
- if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
2940
- if (opts.posix !== false && value === ':') {
2941
- const inner = prev.value.slice(1);
2942
- if (inner.includes('[')) {
2943
- prev.posix = true;
2944
-
2945
- if (inner.includes(':')) {
2946
- const idx = prev.value.lastIndexOf('[');
2947
- const pre = prev.value.slice(0, idx);
2948
- const rest = prev.value.slice(idx + 2);
2949
- const posix = POSIX_REGEX_SOURCE[rest];
2950
- if (posix) {
2951
- prev.value = pre + posix;
2952
- state.backtrack = true;
2953
- advance();
2954
-
2955
- if (!bos.output && tokens.indexOf(prev) === 1) {
2956
- bos.output = ONE_CHAR;
2957
- }
2958
- continue;
2959
- }
2960
- }
2961
- }
2962
- }
2963
-
2964
- if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
2965
- value = `\\${value}`;
2966
- }
2967
-
2968
- if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
2969
- value = `\\${value}`;
2970
- }
2971
-
2972
- if (opts.posix === true && value === '!' && prev.value === '[') {
2973
- value = '^';
2974
- }
2975
-
2976
- prev.value += value;
2977
- append({ value });
2978
- continue;
2979
- }
2980
-
2981
- /**
2982
- * If we're inside a quoted string, continue
2983
- * until we reach the closing double quote.
2984
- */
2985
-
2986
- if (state.quotes === 1 && value !== '"') {
2987
- value = utils$d.escapeRegex(value);
2988
- prev.value += value;
2989
- append({ value });
2990
- continue;
2991
- }
2992
-
2993
- /**
2994
- * Double quotes
2995
- */
2996
-
2997
- if (value === '"') {
2998
- state.quotes = state.quotes === 1 ? 0 : 1;
2999
- if (opts.keepQuotes === true) {
3000
- push({ type: 'text', value });
3001
- }
3002
- continue;
3003
- }
3004
-
3005
- /**
3006
- * Parentheses
3007
- */
3008
-
3009
- if (value === '(') {
3010
- increment('parens');
3011
- push({ type: 'paren', value });
3012
- continue;
3013
- }
3014
-
3015
- if (value === ')') {
3016
- if (state.parens === 0 && opts.strictBrackets === true) {
3017
- throw new SyntaxError(syntaxError('opening', '('));
3018
- }
3019
-
3020
- const extglob = extglobs[extglobs.length - 1];
3021
- if (extglob && state.parens === extglob.parens + 1) {
3022
- extglobClose(extglobs.pop());
3023
- continue;
3024
- }
3025
-
3026
- push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
3027
- decrement('parens');
3028
- continue;
3029
- }
3030
-
3031
- /**
3032
- * Square brackets
3033
- */
3034
-
3035
- if (value === '[') {
3036
- if (opts.nobracket === true || !remaining().includes(']')) {
3037
- if (opts.nobracket !== true && opts.strictBrackets === true) {
3038
- throw new SyntaxError(syntaxError('closing', ']'));
3039
- }
3040
-
3041
- value = `\\${value}`;
3042
- } else {
3043
- increment('brackets');
3044
- }
3045
-
3046
- push({ type: 'bracket', value });
3047
- continue;
3048
- }
3049
-
3050
- if (value === ']') {
3051
- if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
3052
- push({ type: 'text', value, output: `\\${value}` });
3053
- continue;
3054
- }
3055
-
3056
- if (state.brackets === 0) {
3057
- if (opts.strictBrackets === true) {
3058
- throw new SyntaxError(syntaxError('opening', '['));
3059
- }
3060
-
3061
- push({ type: 'text', value, output: `\\${value}` });
3062
- continue;
3063
- }
3064
-
3065
- decrement('brackets');
3066
-
3067
- const prevValue = prev.value.slice(1);
3068
- if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
3069
- value = `/${value}`;
3070
- }
3071
-
3072
- prev.value += value;
3073
- append({ value });
3074
-
3075
- // when literal brackets are explicitly disabled
3076
- // assume we should match with a regex character class
3077
- if (opts.literalBrackets === false || utils$d.hasRegexChars(prevValue)) {
3078
- continue;
3079
- }
3080
-
3081
- const escaped = utils$d.escapeRegex(prev.value);
3082
- state.output = state.output.slice(0, -prev.value.length);
3083
-
3084
- // when literal brackets are explicitly enabled
3085
- // assume we should escape the brackets to match literal characters
3086
- if (opts.literalBrackets === true) {
3087
- state.output += escaped;
3088
- prev.value = escaped;
3089
- continue;
3090
- }
3091
-
3092
- // when the user specifies nothing, try to match both
3093
- prev.value = `(${capture}${escaped}|${prev.value})`;
3094
- state.output += prev.value;
3095
- continue;
3096
- }
3097
-
3098
- /**
3099
- * Braces
3100
- */
3101
-
3102
- if (value === '{' && opts.nobrace !== true) {
3103
- increment('braces');
3104
-
3105
- const open = {
3106
- type: 'brace',
3107
- value,
3108
- output: '(',
3109
- outputIndex: state.output.length,
3110
- tokensIndex: state.tokens.length
3111
- };
3112
-
3113
- braces.push(open);
3114
- push(open);
3115
- continue;
3116
- }
3117
-
3118
- if (value === '}') {
3119
- const brace = braces[braces.length - 1];
3120
-
3121
- if (opts.nobrace === true || !brace) {
3122
- push({ type: 'text', value, output: value });
3123
- continue;
3124
- }
3125
-
3126
- let output = ')';
3127
-
3128
- if (brace.dots === true) {
3129
- const arr = tokens.slice();
3130
- const range = [];
3131
-
3132
- for (let i = arr.length - 1; i >= 0; i--) {
3133
- tokens.pop();
3134
- if (arr[i].type === 'brace') {
3135
- break;
3136
- }
3137
- if (arr[i].type !== 'dots') {
3138
- range.unshift(arr[i].value);
3139
- }
3140
- }
3141
-
3142
- output = expandRange(range, opts);
3143
- state.backtrack = true;
3144
- }
3145
-
3146
- if (brace.comma !== true && brace.dots !== true) {
3147
- const out = state.output.slice(0, brace.outputIndex);
3148
- const toks = state.tokens.slice(brace.tokensIndex);
3149
- brace.value = brace.output = '\\{';
3150
- value = output = '\\}';
3151
- state.output = out;
3152
- for (const t of toks) {
3153
- state.output += (t.output || t.value);
3154
- }
3155
- }
3156
-
3157
- push({ type: 'brace', value, output });
3158
- decrement('braces');
3159
- braces.pop();
3160
- continue;
3161
- }
3162
-
3163
- /**
3164
- * Pipes
3165
- */
3166
-
3167
- if (value === '|') {
3168
- if (extglobs.length > 0) {
3169
- extglobs[extglobs.length - 1].conditions++;
3170
- }
3171
- push({ type: 'text', value });
3172
- continue;
3173
- }
3174
-
3175
- /**
3176
- * Commas
3177
- */
3178
-
3179
- if (value === ',') {
3180
- let output = value;
3181
-
3182
- const brace = braces[braces.length - 1];
3183
- if (brace && stack[stack.length - 1] === 'braces') {
3184
- brace.comma = true;
3185
- output = '|';
3186
- }
3187
-
3188
- push({ type: 'comma', value, output });
3189
- continue;
3190
- }
3191
-
3192
- /**
3193
- * Slashes
3194
- */
3195
-
3196
- if (value === '/') {
3197
- // if the beginning of the glob is "./", advance the start
3198
- // to the current index, and don't add the "./" characters
3199
- // to the state. This greatly simplifies lookbehinds when
3200
- // checking for BOS characters like "!" and "." (not "./")
3201
- if (prev.type === 'dot' && state.index === state.start + 1) {
3202
- state.start = state.index + 1;
3203
- state.consumed = '';
3204
- state.output = '';
3205
- tokens.pop();
3206
- prev = bos; // reset "prev" to the first token
3207
- continue;
3208
- }
3209
-
3210
- push({ type: 'slash', value, output: SLASH_LITERAL });
3211
- continue;
3212
- }
3213
-
3214
- /**
3215
- * Dots
3216
- */
3217
-
3218
- if (value === '.') {
3219
- if (state.braces > 0 && prev.type === 'dot') {
3220
- if (prev.value === '.') prev.output = DOT_LITERAL;
3221
- const brace = braces[braces.length - 1];
3222
- prev.type = 'dots';
3223
- prev.output += value;
3224
- prev.value += value;
3225
- brace.dots = true;
3226
- continue;
3227
- }
3228
-
3229
- if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
3230
- push({ type: 'text', value, output: DOT_LITERAL });
3231
- continue;
3232
- }
3233
-
3234
- push({ type: 'dot', value, output: DOT_LITERAL });
3235
- continue;
3236
- }
3237
-
3238
- /**
3239
- * Question marks
3240
- */
3241
-
3242
- if (value === '?') {
3243
- const isGroup = prev && prev.value === '(';
3244
- if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3245
- extglobOpen('qmark', value);
3246
- continue;
3247
- }
3248
-
3249
- if (prev && prev.type === 'paren') {
3250
- const next = peek();
3251
- let output = value;
3252
-
3253
- if (next === '<' && !utils$d.supportsLookbehinds()) {
3254
- throw new Error('Node.js v10 or higher is required for regex lookbehinds');
3255
- }
3256
-
3257
- if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
3258
- output = `\\${value}`;
3259
- }
3260
-
3261
- push({ type: 'text', value, output });
3262
- continue;
3263
- }
3264
-
3265
- if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
3266
- push({ type: 'qmark', value, output: QMARK_NO_DOT });
3267
- continue;
3268
- }
3269
-
3270
- push({ type: 'qmark', value, output: QMARK });
3271
- continue;
3272
- }
3273
-
3274
- /**
3275
- * Exclamation
3276
- */
3277
-
3278
- if (value === '!') {
3279
- if (opts.noextglob !== true && peek() === '(') {
3280
- if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
3281
- extglobOpen('negate', value);
3282
- continue;
3283
- }
3284
- }
3285
-
3286
- if (opts.nonegate !== true && state.index === 0) {
3287
- negate();
3288
- continue;
3289
- }
3290
- }
3291
-
3292
- /**
3293
- * Plus
3294
- */
3295
-
3296
- if (value === '+') {
3297
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3298
- extglobOpen('plus', value);
3299
- continue;
3300
- }
3301
-
3302
- if ((prev && prev.value === '(') || opts.regex === false) {
3303
- push({ type: 'plus', value, output: PLUS_LITERAL });
3304
- continue;
3305
- }
3306
-
3307
- if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
3308
- push({ type: 'plus', value });
3309
- continue;
3310
- }
3311
-
3312
- push({ type: 'plus', value: PLUS_LITERAL });
3313
- continue;
3314
- }
3315
-
3316
- /**
3317
- * Plain text
3318
- */
3319
-
3320
- if (value === '@') {
3321
- if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
3322
- push({ type: 'at', extglob: true, value, output: '' });
3323
- continue;
3324
- }
3325
-
3326
- push({ type: 'text', value });
3327
- continue;
3328
- }
3329
-
3330
- /**
3331
- * Plain text
3332
- */
3333
-
3334
- if (value !== '*') {
3335
- if (value === '$' || value === '^') {
3336
- value = `\\${value}`;
3337
- }
3338
-
3339
- const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
3340
- if (match) {
3341
- value += match[0];
3342
- state.index += match[0].length;
3343
- }
3344
-
3345
- push({ type: 'text', value });
3346
- continue;
3347
- }
3348
-
3349
- /**
3350
- * Stars
3351
- */
3352
-
3353
- if (prev && (prev.type === 'globstar' || prev.star === true)) {
3354
- prev.type = 'star';
3355
- prev.star = true;
3356
- prev.value += value;
3357
- prev.output = star;
3358
- state.backtrack = true;
3359
- state.globstar = true;
3360
- consume(value);
3361
- continue;
3362
- }
3363
-
3364
- let rest = remaining();
3365
- if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
3366
- extglobOpen('star', value);
3367
- continue;
3368
- }
3369
-
3370
- if (prev.type === 'star') {
3371
- if (opts.noglobstar === true) {
3372
- consume(value);
3373
- continue;
3374
- }
3375
-
3376
- const prior = prev.prev;
3377
- const before = prior.prev;
3378
- const isStart = prior.type === 'slash' || prior.type === 'bos';
3379
- const afterStar = before && (before.type === 'star' || before.type === 'globstar');
3380
-
3381
- if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
3382
- push({ type: 'star', value, output: '' });
3383
- continue;
3384
- }
3385
-
3386
- const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
3387
- const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
3388
- if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
3389
- push({ type: 'star', value, output: '' });
3390
- continue;
3391
- }
3392
-
3393
- // strip consecutive `/**/`
3394
- while (rest.slice(0, 3) === '/**') {
3395
- const after = input[state.index + 4];
3396
- if (after && after !== '/') {
3397
- break;
3398
- }
3399
- rest = rest.slice(3);
3400
- consume('/**', 3);
3401
- }
3402
-
3403
- if (prior.type === 'bos' && eos()) {
3404
- prev.type = 'globstar';
3405
- prev.value += value;
3406
- prev.output = globstar(opts);
3407
- state.output = prev.output;
3408
- state.globstar = true;
3409
- consume(value);
3410
- continue;
3411
- }
3412
-
3413
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
3414
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
3415
- prior.output = `(?:${prior.output}`;
3416
-
3417
- prev.type = 'globstar';
3418
- prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
3419
- prev.value += value;
3420
- state.globstar = true;
3421
- state.output += prior.output + prev.output;
3422
- consume(value);
3423
- continue;
3424
- }
3425
-
3426
- if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
3427
- const end = rest[1] !== void 0 ? '|$' : '';
3428
-
3429
- state.output = state.output.slice(0, -(prior.output + prev.output).length);
3430
- prior.output = `(?:${prior.output}`;
3431
-
3432
- prev.type = 'globstar';
3433
- prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
3434
- prev.value += value;
3435
-
3436
- state.output += prior.output + prev.output;
3437
- state.globstar = true;
3438
-
3439
- consume(value + advance());
3440
-
3441
- push({ type: 'slash', value: '/', output: '' });
3442
- continue;
3443
- }
3444
-
3445
- if (prior.type === 'bos' && rest[0] === '/') {
3446
- prev.type = 'globstar';
3447
- prev.value += value;
3448
- prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
3449
- state.output = prev.output;
3450
- state.globstar = true;
3451
- consume(value + advance());
3452
- push({ type: 'slash', value: '/', output: '' });
3453
- continue;
3454
- }
3455
-
3456
- // remove single star from output
3457
- state.output = state.output.slice(0, -prev.output.length);
3458
-
3459
- // reset previous token to globstar
3460
- prev.type = 'globstar';
3461
- prev.output = globstar(opts);
3462
- prev.value += value;
3463
-
3464
- // reset output with globstar
3465
- state.output += prev.output;
3466
- state.globstar = true;
3467
- consume(value);
3468
- continue;
3469
- }
3470
-
3471
- const token = { type: 'star', value, output: star };
3472
-
3473
- if (opts.bash === true) {
3474
- token.output = '.*?';
3475
- if (prev.type === 'bos' || prev.type === 'slash') {
3476
- token.output = nodot + token.output;
3477
- }
3478
- push(token);
3479
- continue;
3480
- }
3481
-
3482
- if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
3483
- token.output = value;
3484
- push(token);
3485
- continue;
3486
- }
3487
-
3488
- if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
3489
- if (prev.type === 'dot') {
3490
- state.output += NO_DOT_SLASH;
3491
- prev.output += NO_DOT_SLASH;
3492
-
3493
- } else if (opts.dot === true) {
3494
- state.output += NO_DOTS_SLASH;
3495
- prev.output += NO_DOTS_SLASH;
3496
-
3497
- } else {
3498
- state.output += nodot;
3499
- prev.output += nodot;
3500
- }
3501
-
3502
- if (peek() !== '*') {
3503
- state.output += ONE_CHAR;
3504
- prev.output += ONE_CHAR;
3505
- }
3506
- }
3507
-
3508
- push(token);
3509
- }
3510
-
3511
- while (state.brackets > 0) {
3512
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
3513
- state.output = utils$d.escapeLast(state.output, '[');
3514
- decrement('brackets');
3515
- }
3516
-
3517
- while (state.parens > 0) {
3518
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
3519
- state.output = utils$d.escapeLast(state.output, '(');
3520
- decrement('parens');
3521
- }
3522
-
3523
- while (state.braces > 0) {
3524
- if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
3525
- state.output = utils$d.escapeLast(state.output, '{');
3526
- decrement('braces');
3527
- }
3528
-
3529
- if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
3530
- push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
3531
- }
3532
-
3533
- // rebuild the output if we had to backtrack at any point
3534
- if (state.backtrack === true) {
3535
- state.output = '';
3536
-
3537
- for (const token of state.tokens) {
3538
- state.output += token.output != null ? token.output : token.value;
3539
-
3540
- if (token.suffix) {
3541
- state.output += token.suffix;
3542
- }
3543
- }
3544
- }
3545
-
3546
- return state;
3547
- };
3548
-
3549
- /**
3550
- * Fast paths for creating regular expressions for common glob patterns.
3551
- * This can significantly speed up processing and has very little downside
3552
- * impact when none of the fast paths match.
3553
- */
3554
-
3555
- parse$1.fastpaths = (input, options) => {
3556
- const opts = { ...options };
3557
- const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
3558
- const len = input.length;
3559
- if (len > max) {
3560
- throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
3561
- }
3562
-
3563
- input = REPLACEMENTS[input] || input;
3564
- const win32 = utils$d.isWindows(options);
3565
-
3566
- // create constants based on platform, for windows or posix
3567
- const {
3568
- DOT_LITERAL,
3569
- SLASH_LITERAL,
3570
- ONE_CHAR,
3571
- DOTS_SLASH,
3572
- NO_DOT,
3573
- NO_DOTS,
3574
- NO_DOTS_SLASH,
3575
- STAR,
3576
- START_ANCHOR
3577
- } = constants$2.globChars(win32);
3578
-
3579
- const nodot = opts.dot ? NO_DOTS : NO_DOT;
3580
- const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
3581
- const capture = opts.capture ? '' : '?:';
3582
- const state = { negated: false, prefix: '' };
3583
- let star = opts.bash === true ? '.*?' : STAR;
3584
-
3585
- if (opts.capture) {
3586
- star = `(${star})`;
3587
- }
3588
-
3589
- const globstar = opts => {
3590
- if (opts.noglobstar === true) return star;
3591
- return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
3592
- };
3593
-
3594
- const create = str => {
3595
- switch (str) {
3596
- case '*':
3597
- return `${nodot}${ONE_CHAR}${star}`;
3598
-
3599
- case '.*':
3600
- return `${DOT_LITERAL}${ONE_CHAR}${star}`;
3601
-
3602
- case '*.*':
3603
- return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3604
-
3605
- case '*/*':
3606
- return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
3607
-
3608
- case '**':
3609
- return nodot + globstar(opts);
3610
-
3611
- case '**/*':
3612
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
3613
-
3614
- case '**/*.*':
3615
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
3616
-
3617
- case '**/.*':
3618
- return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
3619
-
3620
- default: {
3621
- const match = /^(.*?)\.(\w+)$/.exec(str);
3622
- if (!match) return;
3623
-
3624
- const source = create(match[1]);
3625
- if (!source) return;
3626
-
3627
- return source + DOT_LITERAL + match[2];
3628
- }
3629
- }
3630
- };
3631
-
3632
- const output = utils$d.removePrefix(input, state);
3633
- let source = create(output);
3634
-
3635
- if (source && opts.strictSlashes !== true) {
3636
- source += `${SLASH_LITERAL}?`;
3637
- }
3638
-
3639
- return source;
3640
- };
3641
-
3642
- var parse_1 = parse$1;
3643
-
3644
- const path$6 = k;
3645
- const scan = scan_1;
3646
- const parse = parse_1;
3647
- const utils$c = utils$f;
3648
- const constants$1 = constants$3;
3649
- const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
3650
-
3651
- /**
3652
- * Creates a matcher function from one or more glob patterns. The
3653
- * returned function takes a string to match as its first argument,
3654
- * and returns true if the string is a match. The returned matcher
3655
- * function also takes a boolean as the second argument that, when true,
3656
- * returns an object with additional information.
3657
- *
3658
- * ```js
3659
- * const picomatch = require('picomatch');
3660
- * // picomatch(glob[, options]);
3661
- *
3662
- * const isMatch = picomatch('*.!(*a)');
3663
- * console.log(isMatch('a.a')); //=> false
3664
- * console.log(isMatch('a.b')); //=> true
3665
- * ```
3666
- * @name picomatch
3667
- * @param {String|Array} `globs` One or more glob patterns.
3668
- * @param {Object=} `options`
3669
- * @return {Function=} Returns a matcher function.
3670
- * @api public
3671
- */
3672
-
3673
- const picomatch$1 = (glob, options, returnState = false) => {
3674
- if (Array.isArray(glob)) {
3675
- const fns = glob.map(input => picomatch$1(input, options, returnState));
3676
- const arrayMatcher = str => {
3677
- for (const isMatch of fns) {
3678
- const state = isMatch(str);
3679
- if (state) return state;
3680
- }
3681
- return false;
3682
- };
3683
- return arrayMatcher;
3684
- }
3685
-
3686
- const isState = isObject(glob) && glob.tokens && glob.input;
3687
-
3688
- if (glob === '' || (typeof glob !== 'string' && !isState)) {
3689
- throw new TypeError('Expected pattern to be a non-empty string');
3690
- }
3691
-
3692
- const opts = options || {};
3693
- const posix = utils$c.isWindows(options);
3694
- const regex = isState
3695
- ? picomatch$1.compileRe(glob, options)
3696
- : picomatch$1.makeRe(glob, options, false, true);
3697
-
3698
- const state = regex.state;
3699
- delete regex.state;
3700
-
3701
- let isIgnored = () => false;
3702
- if (opts.ignore) {
3703
- const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
3704
- isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
3705
- }
3706
-
3707
- const matcher = (input, returnObject = false) => {
3708
- const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
3709
- const result = { glob, state, regex, posix, input, output, match, isMatch };
3710
-
3711
- if (typeof opts.onResult === 'function') {
3712
- opts.onResult(result);
3713
- }
3714
-
3715
- if (isMatch === false) {
3716
- result.isMatch = false;
3717
- return returnObject ? result : false;
3718
- }
3719
-
3720
- if (isIgnored(input)) {
3721
- if (typeof opts.onIgnore === 'function') {
3722
- opts.onIgnore(result);
3723
- }
3724
- result.isMatch = false;
3725
- return returnObject ? result : false;
3726
- }
3727
-
3728
- if (typeof opts.onMatch === 'function') {
3729
- opts.onMatch(result);
3730
- }
3731
- return returnObject ? result : true;
3732
- };
3733
-
3734
- if (returnState) {
3735
- matcher.state = state;
3736
- }
3737
-
3738
- return matcher;
3739
- };
3740
-
3741
- /**
3742
- * Test `input` with the given `regex`. This is used by the main
3743
- * `picomatch()` function to test the input string.
3744
- *
3745
- * ```js
3746
- * const picomatch = require('picomatch');
3747
- * // picomatch.test(input, regex[, options]);
3748
- *
3749
- * console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
3750
- * // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
3751
- * ```
3752
- * @param {String} `input` String to test.
3753
- * @param {RegExp} `regex`
3754
- * @return {Object} Returns an object with matching info.
3755
- * @api public
3756
- */
3757
-
3758
- picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
3759
- if (typeof input !== 'string') {
3760
- throw new TypeError('Expected input to be a string');
3761
- }
3762
-
3763
- if (input === '') {
3764
- return { isMatch: false, output: '' };
3765
- }
3766
-
3767
- const opts = options || {};
3768
- const format = opts.format || (posix ? utils$c.toPosixSlashes : null);
3769
- let match = input === glob;
3770
- let output = (match && format) ? format(input) : input;
3771
-
3772
- if (match === false) {
3773
- output = format ? format(input) : input;
3774
- match = output === glob;
3775
- }
3776
-
3777
- if (match === false || opts.capture === true) {
3778
- if (opts.matchBase === true || opts.basename === true) {
3779
- match = picomatch$1.matchBase(input, regex, options, posix);
3780
- } else {
3781
- match = regex.exec(output);
3782
- }
3783
- }
3784
-
3785
- return { isMatch: Boolean(match), match, output };
3786
- };
3787
-
3788
- /**
3789
- * Match the basename of a filepath.
3790
- *
3791
- * ```js
3792
- * const picomatch = require('picomatch');
3793
- * // picomatch.matchBase(input, glob[, options]);
3794
- * console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
3795
- * ```
3796
- * @param {String} `input` String to test.
3797
- * @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
3798
- * @return {Boolean}
3799
- * @api public
3800
- */
3801
-
3802
- picomatch$1.matchBase = (input, glob, options, posix = utils$c.isWindows(options)) => {
3803
- const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
3804
- return regex.test(path$6.basename(input));
3805
- };
3806
-
3807
- /**
3808
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
3809
- *
3810
- * ```js
3811
- * const picomatch = require('picomatch');
3812
- * // picomatch.isMatch(string, patterns[, options]);
3813
- *
3814
- * console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
3815
- * console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
3816
- * ```
3817
- * @param {String|Array} str The string to test.
3818
- * @param {String|Array} patterns One or more glob patterns to use for matching.
3819
- * @param {Object} [options] See available [options](#options).
3820
- * @return {Boolean} Returns true if any patterns match `str`
3821
- * @api public
3822
- */
3823
-
3824
- picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
3825
-
3826
- /**
3827
- * Parse a glob pattern to create the source string for a regular
3828
- * expression.
3829
- *
3830
- * ```js
3831
- * const picomatch = require('picomatch');
3832
- * const result = picomatch.parse(pattern[, options]);
3833
- * ```
3834
- * @param {String} `pattern`
3835
- * @param {Object} `options`
3836
- * @return {Object} Returns an object with useful properties and output to be used as a regex source string.
3837
- * @api public
3838
- */
3839
-
3840
- picomatch$1.parse = (pattern, options) => {
3841
- if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
3842
- return parse(pattern, { ...options, fastpaths: false });
3843
- };
3844
-
3845
- /**
3846
- * Scan a glob pattern to separate the pattern into segments.
3847
- *
3848
- * ```js
3849
- * const picomatch = require('picomatch');
3850
- * // picomatch.scan(input[, options]);
3851
- *
3852
- * const result = picomatch.scan('!./foo/*.js');
3853
- * console.log(result);
3854
- * { prefix: '!./',
3855
- * input: '!./foo/*.js',
3856
- * start: 3,
3857
- * base: 'foo',
3858
- * glob: '*.js',
3859
- * isBrace: false,
3860
- * isBracket: false,
3861
- * isGlob: true,
3862
- * isExtglob: false,
3863
- * isGlobstar: false,
3864
- * negated: true }
3865
- * ```
3866
- * @param {String} `input` Glob pattern to scan.
3867
- * @param {Object} `options`
3868
- * @return {Object} Returns an object with
3869
- * @api public
3870
- */
3871
-
3872
- picomatch$1.scan = (input, options) => scan(input, options);
3873
-
3874
- /**
3875
- * Compile a regular expression from the `state` object returned by the
3876
- * [parse()](#parse) method.
3877
- *
3878
- * @param {Object} `state`
3879
- * @param {Object} `options`
3880
- * @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
3881
- * @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
3882
- * @return {RegExp}
3883
- * @api public
3884
- */
3885
-
3886
- picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
3887
- if (returnOutput === true) {
3888
- return state.output;
3889
- }
3890
-
3891
- const opts = options || {};
3892
- const prepend = opts.contains ? '' : '^';
3893
- const append = opts.contains ? '' : '$';
3894
-
3895
- let source = `${prepend}(?:${state.output})${append}`;
3896
- if (state && state.negated === true) {
3897
- source = `^(?!${source}).*$`;
3898
- }
3899
-
3900
- const regex = picomatch$1.toRegex(source, options);
3901
- if (returnState === true) {
3902
- regex.state = state;
3903
- }
3904
-
3905
- return regex;
3906
- };
3907
-
3908
- /**
3909
- * Create a regular expression from a parsed glob pattern.
3910
- *
3911
- * ```js
3912
- * const picomatch = require('picomatch');
3913
- * const state = picomatch.parse('*.js');
3914
- * // picomatch.compileRe(state[, options]);
3915
- *
3916
- * console.log(picomatch.compileRe(state));
3917
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3918
- * ```
3919
- * @param {String} `state` The object returned from the `.parse` method.
3920
- * @param {Object} `options`
3921
- * @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
3922
- * @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
3923
- * @return {RegExp} Returns a regex created from the given pattern.
3924
- * @api public
3925
- */
3926
-
3927
- picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
3928
- if (!input || typeof input !== 'string') {
3929
- throw new TypeError('Expected a non-empty string');
3930
- }
3931
-
3932
- let parsed = { negated: false, fastpaths: true };
3933
-
3934
- if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
3935
- parsed.output = parse.fastpaths(input, options);
3936
- }
3937
-
3938
- if (!parsed.output) {
3939
- parsed = parse(input, options);
3940
- }
3941
-
3942
- return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
3943
- };
3944
-
3945
- /**
3946
- * Create a regular expression from the given regex source string.
3947
- *
3948
- * ```js
3949
- * const picomatch = require('picomatch');
3950
- * // picomatch.toRegex(source[, options]);
3951
- *
3952
- * const { output } = picomatch.parse('*.js');
3953
- * console.log(picomatch.toRegex(output));
3954
- * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
3955
- * ```
3956
- * @param {String} `source` Regular expression source string.
3957
- * @param {Object} `options`
3958
- * @return {RegExp}
3959
- * @api public
3960
- */
3961
-
3962
- picomatch$1.toRegex = (source, options) => {
3963
- try {
3964
- const opts = options || {};
3965
- return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
3966
- } catch (err) {
3967
- if (options && options.debug === true) throw err;
3968
- return /$^/;
3969
- }
3970
- };
3971
-
3972
- /**
3973
- * Picomatch constants.
3974
- * @return {Object}
3975
- */
3976
-
3977
- picomatch$1.constants = constants$1;
3978
-
3979
- /**
3980
- * Expose "picomatch"
3981
- */
3982
-
3983
- var picomatch_1 = picomatch$1;
3984
-
3985
- (function (module) {
3986
-
3987
- module.exports = picomatch_1;
3988
- } (picomatch$2));
3989
-
3990
- const util = util$2;
3991
- const braces = braces_1;
3992
- const picomatch = picomatch$2.exports;
3993
- const utils$b = utils$f;
3994
- const isEmptyString = val => val === '' || val === './';
3995
-
3996
- /**
3997
- * Returns an array of strings that match one or more glob patterns.
3998
- *
3999
- * ```js
4000
- * const mm = require('micromatch');
4001
- * // mm(list, patterns[, options]);
4002
- *
4003
- * console.log(mm(['a.js', 'a.txt'], ['*.js']));
4004
- * //=> [ 'a.js' ]
4005
- * ```
4006
- * @param {String|Array<string>} `list` List of strings to match.
4007
- * @param {String|Array<string>} `patterns` One or more glob patterns to use for matching.
4008
- * @param {Object} `options` See available [options](#options)
4009
- * @return {Array} Returns an array of matches
4010
- * @summary false
4011
- * @api public
4012
- */
4013
-
4014
- const micromatch$1 = (list, patterns, options) => {
4015
- patterns = [].concat(patterns);
4016
- list = [].concat(list);
4017
-
4018
- let omit = new Set();
4019
- let keep = new Set();
4020
- let items = new Set();
4021
- let negatives = 0;
4022
-
4023
- let onResult = state => {
4024
- items.add(state.output);
4025
- if (options && options.onResult) {
4026
- options.onResult(state);
4027
- }
4028
- };
4029
-
4030
- for (let i = 0; i < patterns.length; i++) {
4031
- let isMatch = picomatch(String(patterns[i]), { ...options, onResult }, true);
4032
- let negated = isMatch.state.negated || isMatch.state.negatedExtglob;
4033
- if (negated) negatives++;
4034
-
4035
- for (let item of list) {
4036
- let matched = isMatch(item, true);
4037
-
4038
- let match = negated ? !matched.isMatch : matched.isMatch;
4039
- if (!match) continue;
4040
-
4041
- if (negated) {
4042
- omit.add(matched.output);
4043
- } else {
4044
- omit.delete(matched.output);
4045
- keep.add(matched.output);
4046
- }
4047
- }
4048
- }
4049
-
4050
- let result = negatives === patterns.length ? [...items] : [...keep];
4051
- let matches = result.filter(item => !omit.has(item));
4052
-
4053
- if (options && matches.length === 0) {
4054
- if (options.failglob === true) {
4055
- throw new Error(`No matches found for "${patterns.join(', ')}"`);
4056
- }
4057
-
4058
- if (options.nonull === true || options.nullglob === true) {
4059
- return options.unescape ? patterns.map(p => p.replace(/\\/g, '')) : patterns;
4060
- }
4061
- }
4062
-
4063
- return matches;
4064
- };
4065
-
4066
- /**
4067
- * Backwards compatibility
4068
- */
4069
-
4070
- micromatch$1.match = micromatch$1;
4071
-
4072
- /**
4073
- * Returns a matcher function from the given glob `pattern` and `options`.
4074
- * The returned function takes a string to match as its only argument and returns
4075
- * true if the string is a match.
4076
- *
4077
- * ```js
4078
- * const mm = require('micromatch');
4079
- * // mm.matcher(pattern[, options]);
4080
- *
4081
- * const isMatch = mm.matcher('*.!(*a)');
4082
- * console.log(isMatch('a.a')); //=> false
4083
- * console.log(isMatch('a.b')); //=> true
4084
- * ```
4085
- * @param {String} `pattern` Glob pattern
4086
- * @param {Object} `options`
4087
- * @return {Function} Returns a matcher function.
4088
- * @api public
4089
- */
4090
-
4091
- micromatch$1.matcher = (pattern, options) => picomatch(pattern, options);
4092
-
4093
- /**
4094
- * Returns true if **any** of the given glob `patterns` match the specified `string`.
4095
- *
4096
- * ```js
4097
- * const mm = require('micromatch');
4098
- * // mm.isMatch(string, patterns[, options]);
4099
- *
4100
- * console.log(mm.isMatch('a.a', ['b.*', '*.a'])); //=> true
4101
- * console.log(mm.isMatch('a.a', 'b.*')); //=> false
4102
- * ```
4103
- * @param {String} `str` The string to test.
4104
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4105
- * @param {Object} `[options]` See available [options](#options).
4106
- * @return {Boolean} Returns true if any patterns match `str`
4107
- * @api public
4108
- */
4109
-
4110
- micromatch$1.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
4111
-
4112
- /**
4113
- * Backwards compatibility
4114
- */
4115
-
4116
- micromatch$1.any = micromatch$1.isMatch;
4117
-
4118
- /**
4119
- * Returns a list of strings that _**do not match any**_ of the given `patterns`.
4120
- *
4121
- * ```js
4122
- * const mm = require('micromatch');
4123
- * // mm.not(list, patterns[, options]);
4124
- *
4125
- * console.log(mm.not(['a.a', 'b.b', 'c.c'], '*.a'));
4126
- * //=> ['b.b', 'c.c']
4127
- * ```
4128
- * @param {Array} `list` Array of strings to match.
4129
- * @param {String|Array} `patterns` One or more glob pattern to use for matching.
4130
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4131
- * @return {Array} Returns an array of strings that **do not match** the given patterns.
4132
- * @api public
4133
- */
4134
-
4135
- micromatch$1.not = (list, patterns, options = {}) => {
4136
- patterns = [].concat(patterns).map(String);
4137
- let result = new Set();
4138
- let items = [];
4139
-
4140
- let onResult = state => {
4141
- if (options.onResult) options.onResult(state);
4142
- items.push(state.output);
4143
- };
4144
-
4145
- let matches = new Set(micromatch$1(list, patterns, { ...options, onResult }));
4146
-
4147
- for (let item of items) {
4148
- if (!matches.has(item)) {
4149
- result.add(item);
4150
- }
4151
- }
4152
- return [...result];
4153
- };
4154
-
4155
- /**
4156
- * Returns true if the given `string` contains the given pattern. Similar
4157
- * to [.isMatch](#isMatch) but the pattern can match any part of the string.
4158
- *
4159
- * ```js
4160
- * var mm = require('micromatch');
4161
- * // mm.contains(string, pattern[, options]);
4162
- *
4163
- * console.log(mm.contains('aa/bb/cc', '*b'));
4164
- * //=> true
4165
- * console.log(mm.contains('aa/bb/cc', '*d'));
4166
- * //=> false
4167
- * ```
4168
- * @param {String} `str` The string to match.
4169
- * @param {String|Array} `patterns` Glob pattern to use for matching.
4170
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4171
- * @return {Boolean} Returns true if any of the patterns matches any part of `str`.
4172
- * @api public
4173
- */
4174
-
4175
- micromatch$1.contains = (str, pattern, options) => {
4176
- if (typeof str !== 'string') {
4177
- throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
4178
- }
4179
-
4180
- if (Array.isArray(pattern)) {
4181
- return pattern.some(p => micromatch$1.contains(str, p, options));
4182
- }
4183
-
4184
- if (typeof pattern === 'string') {
4185
- if (isEmptyString(str) || isEmptyString(pattern)) {
4186
- return false;
4187
- }
4188
-
4189
- if (str.includes(pattern) || (str.startsWith('./') && str.slice(2).includes(pattern))) {
4190
- return true;
4191
- }
4192
- }
4193
-
4194
- return micromatch$1.isMatch(str, pattern, { ...options, contains: true });
4195
- };
4196
-
4197
- /**
4198
- * Filter the keys of the given object with the given `glob` pattern
4199
- * and `options`. Does not attempt to match nested keys. If you need this feature,
4200
- * use [glob-object][] instead.
4201
- *
4202
- * ```js
4203
- * const mm = require('micromatch');
4204
- * // mm.matchKeys(object, patterns[, options]);
4205
- *
4206
- * const obj = { aa: 'a', ab: 'b', ac: 'c' };
4207
- * console.log(mm.matchKeys(obj, '*b'));
4208
- * //=> { ab: 'b' }
4209
- * ```
4210
- * @param {Object} `object` The object with keys to filter.
4211
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4212
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4213
- * @return {Object} Returns an object with only keys that match the given patterns.
4214
- * @api public
4215
- */
4216
-
4217
- micromatch$1.matchKeys = (obj, patterns, options) => {
4218
- if (!utils$b.isObject(obj)) {
4219
- throw new TypeError('Expected the first argument to be an object');
4220
- }
4221
- let keys = micromatch$1(Object.keys(obj), patterns, options);
4222
- let res = {};
4223
- for (let key of keys) res[key] = obj[key];
4224
- return res;
4225
- };
4226
-
4227
- /**
4228
- * Returns true if some of the strings in the given `list` match any of the given glob `patterns`.
4229
- *
4230
- * ```js
4231
- * const mm = require('micromatch');
4232
- * // mm.some(list, patterns[, options]);
4233
- *
4234
- * console.log(mm.some(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
4235
- * // true
4236
- * console.log(mm.some(['foo.js'], ['*.js', '!foo.js']));
4237
- * // false
4238
- * ```
4239
- * @param {String|Array} `list` The string or array of strings to test. Returns as soon as the first match is found.
4240
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4241
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4242
- * @return {Boolean} Returns true if any `patterns` matches any of the strings in `list`
4243
- * @api public
4244
- */
4245
-
4246
- micromatch$1.some = (list, patterns, options) => {
4247
- let items = [].concat(list);
4248
-
4249
- for (let pattern of [].concat(patterns)) {
4250
- let isMatch = picomatch(String(pattern), options);
4251
- if (items.some(item => isMatch(item))) {
4252
- return true;
4253
- }
4254
- }
4255
- return false;
4256
- };
4257
-
4258
- /**
4259
- * Returns true if every string in the given `list` matches
4260
- * any of the given glob `patterns`.
4261
- *
4262
- * ```js
4263
- * const mm = require('micromatch');
4264
- * // mm.every(list, patterns[, options]);
4265
- *
4266
- * console.log(mm.every('foo.js', ['foo.js']));
4267
- * // true
4268
- * console.log(mm.every(['foo.js', 'bar.js'], ['*.js']));
4269
- * // true
4270
- * console.log(mm.every(['foo.js', 'bar.js'], ['*.js', '!foo.js']));
4271
- * // false
4272
- * console.log(mm.every(['foo.js'], ['*.js', '!foo.js']));
4273
- * // false
4274
- * ```
4275
- * @param {String|Array} `list` The string or array of strings to test.
4276
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4277
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4278
- * @return {Boolean} Returns true if all `patterns` matches all of the strings in `list`
4279
- * @api public
4280
- */
4281
-
4282
- micromatch$1.every = (list, patterns, options) => {
4283
- let items = [].concat(list);
4284
-
4285
- for (let pattern of [].concat(patterns)) {
4286
- let isMatch = picomatch(String(pattern), options);
4287
- if (!items.every(item => isMatch(item))) {
4288
- return false;
4289
- }
4290
- }
4291
- return true;
4292
- };
4293
-
4294
- /**
4295
- * Returns true if **all** of the given `patterns` match
4296
- * the specified string.
4297
- *
4298
- * ```js
4299
- * const mm = require('micromatch');
4300
- * // mm.all(string, patterns[, options]);
4301
- *
4302
- * console.log(mm.all('foo.js', ['foo.js']));
4303
- * // true
4304
- *
4305
- * console.log(mm.all('foo.js', ['*.js', '!foo.js']));
4306
- * // false
4307
- *
4308
- * console.log(mm.all('foo.js', ['*.js', 'foo.js']));
4309
- * // true
4310
- *
4311
- * console.log(mm.all('foo.js', ['*.js', 'f*', '*o*', '*o.js']));
4312
- * // true
4313
- * ```
4314
- * @param {String|Array} `str` The string to test.
4315
- * @param {String|Array} `patterns` One or more glob patterns to use for matching.
4316
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4317
- * @return {Boolean} Returns true if any patterns match `str`
4318
- * @api public
4319
- */
4320
-
4321
- micromatch$1.all = (str, patterns, options) => {
4322
- if (typeof str !== 'string') {
4323
- throw new TypeError(`Expected a string: "${util.inspect(str)}"`);
4324
- }
4325
-
4326
- return [].concat(patterns).every(p => picomatch(p, options)(str));
4327
- };
4328
-
4329
- /**
4330
- * Returns an array of matches captured by `pattern` in `string, or `null` if the pattern did not match.
4331
- *
4332
- * ```js
4333
- * const mm = require('micromatch');
4334
- * // mm.capture(pattern, string[, options]);
4335
- *
4336
- * console.log(mm.capture('test/*.js', 'test/foo.js'));
4337
- * //=> ['foo']
4338
- * console.log(mm.capture('test/*.js', 'foo/bar.css'));
4339
- * //=> null
4340
- * ```
4341
- * @param {String} `glob` Glob pattern to use for matching.
4342
- * @param {String} `input` String to match
4343
- * @param {Object} `options` See available [options](#options) for changing how matches are performed
4344
- * @return {Array|null} Returns an array of captures if the input matches the glob pattern, otherwise `null`.
4345
- * @api public
4346
- */
4347
-
4348
- micromatch$1.capture = (glob, input, options) => {
4349
- let posix = utils$b.isWindows(options);
4350
- let regex = picomatch.makeRe(String(glob), { ...options, capture: true });
4351
- let match = regex.exec(posix ? utils$b.toPosixSlashes(input) : input);
4352
-
4353
- if (match) {
4354
- return match.slice(1).map(v => v === void 0 ? '' : v);
4355
- }
4356
- };
4357
-
4358
- /**
4359
- * Create a regular expression from the given glob `pattern`.
4360
- *
4361
- * ```js
4362
- * const mm = require('micromatch');
4363
- * // mm.makeRe(pattern[, options]);
4364
- *
4365
- * console.log(mm.makeRe('*.js'));
4366
- * //=> /^(?:(\.[\\\/])?(?!\.)(?=.)[^\/]*?\.js)$/
4367
- * ```
4368
- * @param {String} `pattern` A glob pattern to convert to regex.
4369
- * @param {Object} `options`
4370
- * @return {RegExp} Returns a regex created from the given pattern.
4371
- * @api public
4372
- */
4373
-
4374
- micromatch$1.makeRe = (...args) => picomatch.makeRe(...args);
4375
-
4376
- /**
4377
- * Scan a glob pattern to separate the pattern into segments. Used
4378
- * by the [split](#split) method.
4379
- *
4380
- * ```js
4381
- * const mm = require('micromatch');
4382
- * const state = mm.scan(pattern[, options]);
4383
- * ```
4384
- * @param {String} `pattern`
4385
- * @param {Object} `options`
4386
- * @return {Object} Returns an object with
4387
- * @api public
4388
- */
4389
-
4390
- micromatch$1.scan = (...args) => picomatch.scan(...args);
4391
-
4392
- /**
4393
- * Parse a glob pattern to create the source string for a regular
4394
- * expression.
4395
- *
4396
- * ```js
4397
- * const mm = require('micromatch');
4398
- * const state = mm.parse(pattern[, options]);
4399
- * ```
4400
- * @param {String} `glob`
4401
- * @param {Object} `options`
4402
- * @return {Object} Returns an object with useful properties and output to be used as regex source string.
4403
- * @api public
4404
- */
4405
-
4406
- micromatch$1.parse = (patterns, options) => {
4407
- let res = [];
4408
- for (let pattern of [].concat(patterns || [])) {
4409
- for (let str of braces(String(pattern), options)) {
4410
- res.push(picomatch.parse(str, options));
4411
- }
4412
- }
4413
- return res;
4414
- };
4415
-
4416
- /**
4417
- * Process the given brace `pattern`.
4418
- *
4419
- * ```js
4420
- * const { braces } = require('micromatch');
4421
- * console.log(braces('foo/{a,b,c}/bar'));
4422
- * //=> [ 'foo/(a|b|c)/bar' ]
4423
- *
4424
- * console.log(braces('foo/{a,b,c}/bar', { expand: true }));
4425
- * //=> [ 'foo/a/bar', 'foo/b/bar', 'foo/c/bar' ]
4426
- * ```
4427
- * @param {String} `pattern` String with brace pattern to process.
4428
- * @param {Object} `options` Any [options](#options) to change how expansion is performed. See the [braces][] library for all available options.
4429
- * @return {Array}
4430
- * @api public
4431
- */
4432
-
4433
- micromatch$1.braces = (pattern, options) => {
4434
- if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4435
- if ((options && options.nobrace === true) || !/\{.*\}/.test(pattern)) {
4436
- return [pattern];
4437
- }
4438
- return braces(pattern, options);
4439
- };
4440
-
4441
- /**
4442
- * Expand braces
4443
- */
4444
-
4445
- micromatch$1.braceExpand = (pattern, options) => {
4446
- if (typeof pattern !== 'string') throw new TypeError('Expected a string');
4447
- return micromatch$1.braces(pattern, { ...options, expand: true });
4448
- };
4449
-
4450
- /**
4451
- * Expose micromatch
4452
- */
4453
-
4454
- var micromatch_1 = micromatch$1;
4455
-
4456
497
  Object.defineProperty(pattern$1, "__esModule", { value: true });
4457
498
  pattern$1.matchAny = pattern$1.convertPatternsToRe = pattern$1.makeRe = pattern$1.getPatternParts = pattern$1.expandBraceExpansion = pattern$1.expandPatternsWithBraceExpansion = pattern$1.isAffectDepthOfReadingPattern = pattern$1.endsWithSlashGlobStar = pattern$1.hasGlobStar = pattern$1.getBaseDirectory = pattern$1.isPatternRelatedToParentDirectory = pattern$1.getPatternsOutsideCurrentDirectory = pattern$1.getPatternsInsideCurrentDirectory = pattern$1.getPositivePatterns = pattern$1.getNegativePatterns = pattern$1.isPositivePattern = pattern$1.isNegativePattern = pattern$1.convertToNegativePattern = pattern$1.convertToPositivePattern = pattern$1.isDynamicPattern = pattern$1.isStaticPattern = void 0;
4458
499
  const path$5 = k;
@@ -4798,26 +839,26 @@ function isEmpty(input) {
4798
839
  }
4799
840
  string$1.isEmpty = isEmpty;
4800
841
 
4801
- Object.defineProperty(utils$k, "__esModule", { value: true });
4802
- utils$k.string = utils$k.stream = utils$k.pattern = utils$k.path = utils$k.fs = utils$k.errno = utils$k.array = void 0;
842
+ Object.defineProperty(utils$b, "__esModule", { value: true });
843
+ utils$b.string = utils$b.stream = utils$b.pattern = utils$b.path = utils$b.fs = utils$b.errno = utils$b.array = void 0;
4803
844
  const array = array$1;
4804
- utils$k.array = array;
845
+ utils$b.array = array;
4805
846
  const errno = errno$1;
4806
- utils$k.errno = errno;
847
+ utils$b.errno = errno;
4807
848
  const fs$6 = fs$7;
4808
- utils$k.fs = fs$6;
4809
- const path$4 = path$9;
4810
- utils$k.path = path$4;
849
+ utils$b.fs = fs$6;
850
+ const path$4 = path$7;
851
+ utils$b.path = path$4;
4811
852
  const pattern = pattern$1;
4812
- utils$k.pattern = pattern;
853
+ utils$b.pattern = pattern;
4813
854
  const stream$3 = stream$4;
4814
- utils$k.stream = stream$3;
855
+ utils$b.stream = stream$3;
4815
856
  const string = string$1;
4816
- utils$k.string = string;
857
+ utils$b.string = string;
4817
858
 
4818
859
  Object.defineProperty(tasks, "__esModule", { value: true });
4819
860
  tasks.convertPatternGroupToTask = tasks.convertPatternGroupsToTasks = tasks.groupPatternsByBaseDirectory = tasks.getNegativePatternsAsPositive = tasks.getPositivePatterns = tasks.convertPatternsToTasks = tasks.generate = void 0;
4820
- const utils$a = utils$k;
861
+ const utils$a = utils$b;
4821
862
  function generate(patterns, settings) {
4822
863
  const positivePatterns = getPositivePatterns(patterns);
4823
864
  const negativePatterns = getNegativePatternsAsPositive(patterns, settings.ignore);
@@ -6092,7 +2133,7 @@ var reader = {};
6092
2133
  Object.defineProperty(reader, "__esModule", { value: true });
6093
2134
  const path$1 = k;
6094
2135
  const fsStat$2 = out$1;
6095
- const utils$6 = utils$k;
2136
+ const utils$6 = utils$b;
6096
2137
  class Reader {
6097
2138
  constructor(_settings) {
6098
2139
  this._settings = _settings;
@@ -6223,7 +2264,7 @@ var partial = {};
6223
2264
  var matcher = {};
6224
2265
 
6225
2266
  Object.defineProperty(matcher, "__esModule", { value: true });
6226
- const utils$5 = utils$k;
2267
+ const utils$5 = utils$b;
6227
2268
  class Matcher {
6228
2269
  constructor(_patterns, _settings, _micromatchOptions) {
6229
2270
  this._patterns = _patterns;
@@ -6311,7 +2352,7 @@ class PartialMatcher extends matcher_1.default {
6311
2352
  partial.default = PartialMatcher;
6312
2353
 
6313
2354
  Object.defineProperty(deep, "__esModule", { value: true });
6314
- const utils$4 = utils$k;
2355
+ const utils$4 = utils$b;
6315
2356
  const partial_1 = partial;
6316
2357
  class DeepFilter {
6317
2358
  constructor(_settings, _micromatchOptions) {
@@ -6375,7 +2416,7 @@ deep.default = DeepFilter;
6375
2416
  var entry$1 = {};
6376
2417
 
6377
2418
  Object.defineProperty(entry$1, "__esModule", { value: true });
6378
- const utils$3 = utils$k;
2419
+ const utils$3 = utils$b;
6379
2420
  class EntryFilter {
6380
2421
  constructor(_settings, _micromatchOptions) {
6381
2422
  this._settings = _settings;
@@ -6441,7 +2482,7 @@ entry$1.default = EntryFilter;
6441
2482
  var error = {};
6442
2483
 
6443
2484
  Object.defineProperty(error, "__esModule", { value: true });
6444
- const utils$2 = utils$k;
2485
+ const utils$2 = utils$b;
6445
2486
  class ErrorFilter {
6446
2487
  constructor(_settings) {
6447
2488
  this._settings = _settings;
@@ -6458,7 +2499,7 @@ error.default = ErrorFilter;
6458
2499
  var entry = {};
6459
2500
 
6460
2501
  Object.defineProperty(entry, "__esModule", { value: true });
6461
- const utils$1 = utils$k;
2502
+ const utils$1 = utils$b;
6462
2503
  class EntryTransformer {
6463
2504
  constructor(_settings) {
6464
2505
  this._settings = _settings;
@@ -6724,7 +2765,7 @@ const async_1 = async$7;
6724
2765
  const stream_1 = stream;
6725
2766
  const sync_1 = sync$1;
6726
2767
  const settings_1 = settings;
6727
- const utils = utils$k;
2768
+ const utils = utils$b;
6728
2769
  async function FastGlob(source, options) {
6729
2770
  assertPatternsInput(source);
6730
2771
  const works = getWorks(source, async_1.default, options);
@@ -6895,11 +2936,11 @@ async function makeTscErrorInfo(errInfo) {
6895
2936
  }
6896
2937
  async function getTsconfig(root, config) {
6897
2938
  var _a;
6898
- const tempConfigPath = join(root, "tsconfig.temp.json");
6899
2939
  const configName = ((_a = config.tsconfig) == null ? void 0 : _a.includes("jsconfig.json")) ? "jsconfig.json" : void 0;
6900
2940
  const tsconfig = fn(config.tsconfig || root, configName);
6901
2941
  if (!tsconfig)
6902
2942
  throw new Error("no tsconfig.json found");
2943
+ const tempConfigPath = join(dirname(tsconfig.path), "tsconfig.vitest-temp.json");
6903
2944
  try {
6904
2945
  const tmpTsConfig = { ...tsconfig.config };
6905
2946
  tmpTsConfig.compilerOptions = tmpTsConfig.compilerOptions || {};
@@ -6963,7 +3004,7 @@ async function collectTests(ctx, filepath) {
6963
3004
  const request = await ctx.vitenode.transformRequest(filepath);
6964
3005
  if (!request)
6965
3006
  return null;
6966
- const ast = parse$4(request.code, {
3007
+ const ast = parse(request.code, {
6967
3008
  ecmaVersion: "latest",
6968
3009
  allowAwaitOutsideFunction: true
6969
3010
  });
@@ -7318,18 +3359,25 @@ function createPool(ctx) {
7318
3359
  const maxThreads = ctx.config.maxThreads ?? threadsCount;
7319
3360
  const minThreads = ctx.config.minThreads ?? threadsCount;
7320
3361
  const conditions = ((_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["--conditions", c])) || [];
3362
+ const execArgv = process.execArgv.filter(
3363
+ (execArg) => execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof")
3364
+ );
7321
3365
  const options = {
7322
3366
  filename: workerPath,
7323
3367
  useAtomics: false,
7324
3368
  maxThreads,
7325
3369
  minThreads,
7326
3370
  execArgv: ctx.config.deps.registerNodeLoader ? [
3371
+ ...execArgv,
7327
3372
  "--require",
7328
3373
  suppressLoaderWarningsPath,
7329
3374
  "--experimental-loader",
7330
3375
  loaderPath,
7331
3376
  ...conditions
7332
- ] : conditions
3377
+ ] : [
3378
+ ...execArgv,
3379
+ ...conditions
3380
+ ]
7333
3381
  };
7334
3382
  if (ctx.config.isolate) {
7335
3383
  options.isolateWorkers = true;
@@ -7390,7 +3438,10 @@ function createPool(ctx) {
7390
3438
  return {
7391
3439
  runTests: runWithFiles("run"),
7392
3440
  close: async () => {
7393
- await Promise.all(pool.threads.map((w) => w.terminate()));
3441
+ var _a2;
3442
+ const nodeVersion = Number((_a2 = process.version.match(/v(\d+)\.(\d+)/)) == null ? void 0 : _a2[0].slice(1));
3443
+ if (nodeVersion >= 16.17)
3444
+ await Promise.all(pool.threads.map((w) => w.terminate()));
7394
3445
  }
7395
3446
  };
7396
3447
  }
@@ -7445,8 +3496,8 @@ function createChannel(ctx) {
7445
3496
  ctx.state.updateUserLog(log);
7446
3497
  ctx.report("onUserConsoleLog", log);
7447
3498
  },
7448
- onUnhandledRejection(err) {
7449
- ctx.state.catchError(err, "Unhandled Rejection");
3499
+ onUnhandledError(err, type) {
3500
+ ctx.state.catchError(err, type);
7450
3501
  },
7451
3502
  onFinished(files) {
7452
3503
  ctx.report("onFinished", files, ctx.state.getUnhandledErrors());
@@ -7647,7 +3698,7 @@ class BaseReporter {
7647
3698
  constructor() {
7648
3699
  this.start = 0;
7649
3700
  this.end = 0;
7650
- this.isTTY = isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !process.env.CI;
3701
+ this.isTTY = isNode && ((_a = process.stdout) == null ? void 0 : _a.isTTY) && !isCI;
7651
3702
  this.ctx = void 0;
7652
3703
  this._filesInWatchMode = /* @__PURE__ */ new Map();
7653
3704
  this._lastRunTimeout = 0;
@@ -7839,7 +3890,7 @@ ${BADGE}${TRIGGER} ${c.blue(`x${rerun}`)}
7839
3890
  var _a2, _b, _c;
7840
3891
  return ((_a2 = t.meta) == null ? void 0 : _a2.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
7841
3892
  });
7842
- logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed} failed`)) : c.dim("no errors"));
3893
+ logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed.length} failed`)) : c.dim("no errors"));
7843
3894
  }
7844
3895
  logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
7845
3896
  if (this.watchFilters)
@@ -7944,6 +3995,17 @@ ${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
7944
3995
  }
7945
3996
  }
7946
3997
 
3998
+ class BasicReporter extends BaseReporter {
3999
+ constructor() {
4000
+ super(...arguments);
4001
+ this.isTTY = false;
4002
+ }
4003
+ reportSummary(files) {
4004
+ this.ctx.logger.log();
4005
+ return super.reportSummary(files);
4006
+ }
4007
+ }
4008
+
7947
4009
  const DURATION_LONG$1 = 300;
7948
4010
  const outputMap$1 = /* @__PURE__ */ new WeakMap();
7949
4011
  function formatFilepath$1(path) {
@@ -8974,6 +5036,7 @@ const BenchmarkReportsMap = {
8974
5036
 
8975
5037
  const ReportersMap = {
8976
5038
  "default": DefaultReporter,
5039
+ "basic": BasicReporter,
8977
5040
  "verbose": VerboseReporter,
8978
5041
  "dot": DotReporter,
8979
5042
  "json": JsonReporter$1,
@@ -9129,7 +5192,7 @@ class StateManager {
9129
5192
  }
9130
5193
 
9131
5194
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
9132
- const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*"];
5195
+ const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
9133
5196
  const benchmarkConfigDefaults = {
9134
5197
  include: ["**/*.{bench,benchmark}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
9135
5198
  exclude: defaultExclude,
@@ -9147,20 +5210,17 @@ const defaultCoverageExcludes = [
9147
5210
  "**/*{.,-}test.{js,cjs,mjs,ts,tsx,jsx}",
9148
5211
  "**/*{.,-}spec.{js,cjs,mjs,ts,tsx,jsx}",
9149
5212
  "**/__tests__/**",
9150
- "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress}.config.*",
5213
+ "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
9151
5214
  "**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
9152
5215
  ];
9153
5216
  const coverageConfigDefaults = {
9154
- all: false,
9155
5217
  provider: "c8",
9156
5218
  enabled: false,
9157
5219
  clean: true,
9158
5220
  cleanOnRerun: true,
9159
5221
  reportsDirectory: "./coverage",
9160
- excludeNodeModules: true,
9161
5222
  exclude: defaultCoverageExcludes,
9162
5223
  reporter: ["text", "html", "clover", "json"],
9163
- allowExternal: false,
9164
5224
  extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"]
9165
5225
  };
9166
5226
  const fakeTimersDefaults = {
@@ -9177,8 +5237,8 @@ const fakeTimersDefaults = {
9177
5237
  ]
9178
5238
  };
9179
5239
  const config = {
9180
- allowOnly: !process.env.CI,
9181
- watch: !process.env.CI,
5240
+ allowOnly: !isCI,
5241
+ watch: !isCI,
9182
5242
  globals: false,
9183
5243
  environment: "node",
9184
5244
  threads: true,
@@ -9456,11 +5516,10 @@ function resolveConfig(mode, options, viteConfig) {
9456
5516
  }
9457
5517
  (_c = resolved.deps).registerNodeLoader ?? (_c.registerNodeLoader = false);
9458
5518
  resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
9459
- const CI = !!process.env.CI;
9460
5519
  const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
9461
5520
  resolved.snapshotOptions = {
9462
5521
  snapshotFormat: resolved.snapshotFormat || {},
9463
- updateSnapshot: CI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
5522
+ updateSnapshot: isCI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
9464
5523
  resolveSnapshotPath: options.resolveSnapshotPath
9465
5524
  };
9466
5525
  if (options.resolveSnapshotPath)
@@ -9494,6 +5553,7 @@ function resolveConfig(mode, options, viteConfig) {
9494
5553
  resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
9495
5554
  )
9496
5555
  );
5556
+ resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => relative(resolved.root, file)));
9497
5557
  resolved.forceRerunTriggers = [
9498
5558
  ...resolved.forceRerunTriggers,
9499
5559
  ...resolved.setupFiles
@@ -9526,6 +5586,7 @@ function resolveConfig(mode, options, viteConfig) {
9526
5586
  ...configDefaults.typecheck,
9527
5587
  ...resolved.typecheck
9528
5588
  };
5589
+ resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
9529
5590
  if (mode === "typecheck") {
9530
5591
  resolved.include = resolved.typecheck.include;
9531
5592
  resolved.exclude = resolved.typecheck.exclude;
@@ -10019,7 +6080,7 @@ createLogUpdate(process$1.stdout);
10019
6080
 
10020
6081
  createLogUpdate(process$1.stderr);
10021
6082
 
10022
- var version = "0.27.2";
6083
+ var version = "0.27.3";
10023
6084
 
10024
6085
  function formatLine(line, outputTruncateLength) {
10025
6086
  var _a;
@@ -10155,7 +6216,7 @@ async function printError(error, ctx, options = {}) {
10155
6216
  if (testName) {
10156
6217
  ctx.logger.error(c.red(`The latest test that might've caused the error is "${c.bold(testName)}". It might mean one of the following:
10157
6218
  - The error was thrown, while Vitest was running this test.
10158
- - This was the last recorder test before the error was thrown, if error originated after test finished its execution.`));
6219
+ - This was the last recorded test before the error was thrown, if error originated after test finished its execution.`));
10159
6220
  }
10160
6221
  if (typeof e.cause === "object" && e.cause && "name" in e.cause) {
10161
6222
  e.cause.name = `Caused by: ${e.cause.name}`;
@@ -10163,7 +6224,7 @@ async function printError(error, ctx, options = {}) {
10163
6224
  }
10164
6225
  handleImportOutsideModuleError(e.stack || e.stackStr || "", ctx);
10165
6226
  if (e.showDiff || e.showDiff === void 0 && e.actual && e.expected) {
10166
- displayDiff(stringify$5(e.actual), stringify$5(e.expected), ctx.logger.console, {
6227
+ displayDiff(stringify(e.actual), stringify(e.expected), ctx.logger.console, {
10167
6228
  outputTruncateLength: ctx.config.outputTruncateLength,
10168
6229
  outputDiffLines: ctx.config.outputDiffLines,
10169
6230
  outputDiffMaxLines: ctx.config.outputDiffMaxLines
@@ -10256,7 +6317,7 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
10256
6317
  const hasProperties = Object.keys(errorProperties).length > 0;
10257
6318
  if (hasProperties) {
10258
6319
  logger.error(c.red(c.dim(divider())));
10259
- const propertiesString = stringify$5(errorProperties, 10, { printBasicPrototype: false });
6320
+ const propertiesString = stringify(errorProperties, 10, { printBasicPrototype: false });
10260
6321
  logger.error(c.red(c.bold("Serialized Error:")), c.gray(propertiesString));
10261
6322
  }
10262
6323
  }
@@ -10612,7 +6673,7 @@ class Vitest {
10612
6673
  }
10613
6674
  async filterTestsBySource(tests) {
10614
6675
  if (this.config.changed && !this.config.related) {
10615
- const { VitestGit } = await import('./chunk-node-git.125c9008.js');
6676
+ const { VitestGit } = await import('./chunk-node-git.59caac18.js');
10616
6677
  const vitestGit = new VitestGit(this.config.root);
10617
6678
  const related2 = await vitestGit.findChangedFiles({
10618
6679
  changedSince: this.config.changed
@@ -10668,7 +6729,7 @@ class Vitest {
10668
6729
  })().finally(async () => {
10669
6730
  this.state.finishCollectingPaths();
10670
6731
  if (!this.config.browser)
10671
- await this.report("onFinished", this.state.getFiles(), this.state.getUnhandledErrors());
6732
+ await this.report("onFinished", this.state.getFiles(paths), this.state.getUnhandledErrors());
10672
6733
  this.runningPromise = void 0;
10673
6734
  });
10674
6735
  return await this.runningPromise;
@@ -11330,7 +7391,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11330
7391
  try {
11331
7392
  await ctx.setServer(options, server);
11332
7393
  if (options.api && options.watch)
11333
- (await import('./chunk-api-setup.029198e3.js')).setup(ctx);
7394
+ (await import('./chunk-api-setup.0a2398d8.js')).setup(ctx);
11334
7395
  } catch (err) {
11335
7396
  ctx.logger.printError(err, true);
11336
7397
  process.exit(1);