@vscode/test-web 0.0.49 → 0.0.51
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.
- package/fs-provider/dist/fsExtensionMain.js +2161 -2
- package/fs-provider/package-lock.json +176 -171
- package/fs-provider/package.json +8 -4
- package/package.json +10 -10
|
@@ -27,6 +27,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
27
27
|
exports.MemFileSystemProvider = void 0;
|
|
28
28
|
const vscode_1 = __webpack_require__(2);
|
|
29
29
|
const vscode_uri_1 = __webpack_require__(4);
|
|
30
|
+
const minimatch_1 = __webpack_require__(6);
|
|
30
31
|
function newFileStat(type, size) {
|
|
31
32
|
return Promise.resolve({ type, ctime: Date.now(), mtime: Date.now(), size });
|
|
32
33
|
}
|
|
@@ -34,9 +35,10 @@ function modifiedFileStat(stats, size) {
|
|
|
34
35
|
return Promise.resolve({ type: stats.type, ctime: stats.ctime, mtime: Date.now(), size: size ?? stats.size });
|
|
35
36
|
}
|
|
36
37
|
class MemFileSystemProvider {
|
|
37
|
-
constructor(scheme, root) {
|
|
38
|
+
constructor(scheme, root, extensionUri) {
|
|
38
39
|
this.scheme = scheme;
|
|
39
40
|
this.root = root;
|
|
41
|
+
this.extensionUri = extensionUri;
|
|
40
42
|
// --- manage file events
|
|
41
43
|
this._onDidChangeFile = new vscode_1.EventEmitter();
|
|
42
44
|
this.onDidChangeFile = this._onDidChangeFile.event;
|
|
@@ -123,6 +125,33 @@ class MemFileSystemProvider {
|
|
|
123
125
|
parent.stats = modifiedFileStat(stats, stats.size + 1);
|
|
124
126
|
this._fireSoon({ type: vscode_1.FileChangeType.Changed, uri: dirname }, { type: vscode_1.FileChangeType.Created, uri });
|
|
125
127
|
}
|
|
128
|
+
// --- search
|
|
129
|
+
async provideFileSearchResults(query, options, token) {
|
|
130
|
+
const pattern = query.pattern;
|
|
131
|
+
// Pattern is always blank: https://github.com/microsoft/vscode/issues/200892
|
|
132
|
+
const glob = pattern ? new minimatch_1.Minimatch(pattern) : undefined;
|
|
133
|
+
const result = [];
|
|
134
|
+
const dive = async (currentDirectory, pathSegments = []) => {
|
|
135
|
+
for (const [name, entry] of await currentDirectory.entries) {
|
|
136
|
+
if (typeof options.maxResults !== 'undefined' && result.length >= options.maxResults) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
const uri = vscode_1.Uri.joinPath(this.extensionUri, ...pathSegments, entry.name);
|
|
140
|
+
if (entry.type === vscode_1.FileType.File) {
|
|
141
|
+
const toMatch = uri.toString();
|
|
142
|
+
// Pattern is always blank: https://github.com/microsoft/vscode/issues/200892
|
|
143
|
+
if (!glob || glob.match(toMatch)) {
|
|
144
|
+
result.push(uri);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else if (entry.type === vscode_1.FileType.Directory) {
|
|
148
|
+
await dive(entry, [...pathSegments, name]);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
await dive(this.root);
|
|
153
|
+
return result;
|
|
154
|
+
}
|
|
126
155
|
async _lookup(uri, silent) {
|
|
127
156
|
if (uri.scheme !== this.scheme) {
|
|
128
157
|
if (!silent) {
|
|
@@ -394,6 +423,2133 @@ process.chdir = function (dir) {
|
|
|
394
423
|
process.umask = function() { return 0; };
|
|
395
424
|
|
|
396
425
|
|
|
426
|
+
/***/ }),
|
|
427
|
+
/* 6 */
|
|
428
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
429
|
+
|
|
430
|
+
"use strict";
|
|
431
|
+
/* provided dependency */ var process = __webpack_require__(5);
|
|
432
|
+
|
|
433
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
434
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
435
|
+
};
|
|
436
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
437
|
+
exports.unescape = exports.escape = exports.AST = exports.Minimatch = exports.match = exports.makeRe = exports.braceExpand = exports.defaults = exports.filter = exports.GLOBSTAR = exports.sep = exports.minimatch = void 0;
|
|
438
|
+
const brace_expansion_1 = __importDefault(__webpack_require__(7));
|
|
439
|
+
const assert_valid_pattern_js_1 = __webpack_require__(9);
|
|
440
|
+
const ast_js_1 = __webpack_require__(10);
|
|
441
|
+
const escape_js_1 = __webpack_require__(13);
|
|
442
|
+
const unescape_js_1 = __webpack_require__(12);
|
|
443
|
+
const minimatch = (p, pattern, options = {}) => {
|
|
444
|
+
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
445
|
+
// shortcut: comments match nothing.
|
|
446
|
+
if (!options.nocomment && pattern.charAt(0) === '#') {
|
|
447
|
+
return false;
|
|
448
|
+
}
|
|
449
|
+
return new Minimatch(pattern, options).match(p);
|
|
450
|
+
};
|
|
451
|
+
exports.minimatch = minimatch;
|
|
452
|
+
// Optimized checking for the most common glob patterns.
|
|
453
|
+
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
|
|
454
|
+
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
|
|
455
|
+
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
456
|
+
const starDotExtTestNocase = (ext) => {
|
|
457
|
+
ext = ext.toLowerCase();
|
|
458
|
+
return (f) => !f.startsWith('.') && f.toLowerCase().endsWith(ext);
|
|
459
|
+
};
|
|
460
|
+
const starDotExtTestNocaseDot = (ext) => {
|
|
461
|
+
ext = ext.toLowerCase();
|
|
462
|
+
return (f) => f.toLowerCase().endsWith(ext);
|
|
463
|
+
};
|
|
464
|
+
const starDotStarRE = /^\*+\.\*+$/;
|
|
465
|
+
const starDotStarTest = (f) => !f.startsWith('.') && f.includes('.');
|
|
466
|
+
const starDotStarTestDot = (f) => f !== '.' && f !== '..' && f.includes('.');
|
|
467
|
+
const dotStarRE = /^\.\*+$/;
|
|
468
|
+
const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
|
|
469
|
+
const starRE = /^\*+$/;
|
|
470
|
+
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
|
|
471
|
+
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
|
|
472
|
+
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
|
|
473
|
+
const qmarksTestNocase = ([$0, ext = '']) => {
|
|
474
|
+
const noext = qmarksTestNoExt([$0]);
|
|
475
|
+
if (!ext)
|
|
476
|
+
return noext;
|
|
477
|
+
ext = ext.toLowerCase();
|
|
478
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
479
|
+
};
|
|
480
|
+
const qmarksTestNocaseDot = ([$0, ext = '']) => {
|
|
481
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
482
|
+
if (!ext)
|
|
483
|
+
return noext;
|
|
484
|
+
ext = ext.toLowerCase();
|
|
485
|
+
return (f) => noext(f) && f.toLowerCase().endsWith(ext);
|
|
486
|
+
};
|
|
487
|
+
const qmarksTestDot = ([$0, ext = '']) => {
|
|
488
|
+
const noext = qmarksTestNoExtDot([$0]);
|
|
489
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
490
|
+
};
|
|
491
|
+
const qmarksTest = ([$0, ext = '']) => {
|
|
492
|
+
const noext = qmarksTestNoExt([$0]);
|
|
493
|
+
return !ext ? noext : (f) => noext(f) && f.endsWith(ext);
|
|
494
|
+
};
|
|
495
|
+
const qmarksTestNoExt = ([$0]) => {
|
|
496
|
+
const len = $0.length;
|
|
497
|
+
return (f) => f.length === len && !f.startsWith('.');
|
|
498
|
+
};
|
|
499
|
+
const qmarksTestNoExtDot = ([$0]) => {
|
|
500
|
+
const len = $0.length;
|
|
501
|
+
return (f) => f.length === len && f !== '.' && f !== '..';
|
|
502
|
+
};
|
|
503
|
+
/* c8 ignore start */
|
|
504
|
+
const defaultPlatform = (typeof process === 'object' && process
|
|
505
|
+
? (typeof process.env === 'object' &&
|
|
506
|
+
process.env &&
|
|
507
|
+
process.env.__MINIMATCH_TESTING_PLATFORM__) ||
|
|
508
|
+
process.platform
|
|
509
|
+
: 'posix');
|
|
510
|
+
const path = {
|
|
511
|
+
win32: { sep: '\\' },
|
|
512
|
+
posix: { sep: '/' },
|
|
513
|
+
};
|
|
514
|
+
/* c8 ignore stop */
|
|
515
|
+
exports.sep = defaultPlatform === 'win32' ? path.win32.sep : path.posix.sep;
|
|
516
|
+
exports.minimatch.sep = exports.sep;
|
|
517
|
+
exports.GLOBSTAR = Symbol('globstar **');
|
|
518
|
+
exports.minimatch.GLOBSTAR = exports.GLOBSTAR;
|
|
519
|
+
// any single thing other than /
|
|
520
|
+
// don't need to escape / when using new RegExp()
|
|
521
|
+
const qmark = '[^/]';
|
|
522
|
+
// * => any number of characters
|
|
523
|
+
const star = qmark + '*?';
|
|
524
|
+
// ** when dots are allowed. Anything goes, except .. and .
|
|
525
|
+
// not (^ or / followed by one or two dots followed by $ or /),
|
|
526
|
+
// followed by anything, any number of times.
|
|
527
|
+
const twoStarDot = '(?:(?!(?:\\/|^)(?:\\.{1,2})($|\\/)).)*?';
|
|
528
|
+
// not a ^ or / followed by a dot,
|
|
529
|
+
// followed by anything, any number of times.
|
|
530
|
+
const twoStarNoDot = '(?:(?!(?:\\/|^)\\.).)*?';
|
|
531
|
+
const filter = (pattern, options = {}) => (p) => (0, exports.minimatch)(p, pattern, options);
|
|
532
|
+
exports.filter = filter;
|
|
533
|
+
exports.minimatch.filter = exports.filter;
|
|
534
|
+
const ext = (a, b = {}) => Object.assign({}, a, b);
|
|
535
|
+
const defaults = (def) => {
|
|
536
|
+
if (!def || typeof def !== 'object' || !Object.keys(def).length) {
|
|
537
|
+
return exports.minimatch;
|
|
538
|
+
}
|
|
539
|
+
const orig = exports.minimatch;
|
|
540
|
+
const m = (p, pattern, options = {}) => orig(p, pattern, ext(def, options));
|
|
541
|
+
return Object.assign(m, {
|
|
542
|
+
Minimatch: class Minimatch extends orig.Minimatch {
|
|
543
|
+
constructor(pattern, options = {}) {
|
|
544
|
+
super(pattern, ext(def, options));
|
|
545
|
+
}
|
|
546
|
+
static defaults(options) {
|
|
547
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
548
|
+
}
|
|
549
|
+
},
|
|
550
|
+
AST: class AST extends orig.AST {
|
|
551
|
+
/* c8 ignore start */
|
|
552
|
+
constructor(type, parent, options = {}) {
|
|
553
|
+
super(type, parent, ext(def, options));
|
|
554
|
+
}
|
|
555
|
+
/* c8 ignore stop */
|
|
556
|
+
static fromGlob(pattern, options = {}) {
|
|
557
|
+
return orig.AST.fromGlob(pattern, ext(def, options));
|
|
558
|
+
}
|
|
559
|
+
},
|
|
560
|
+
unescape: (s, options = {}) => orig.unescape(s, ext(def, options)),
|
|
561
|
+
escape: (s, options = {}) => orig.escape(s, ext(def, options)),
|
|
562
|
+
filter: (pattern, options = {}) => orig.filter(pattern, ext(def, options)),
|
|
563
|
+
defaults: (options) => orig.defaults(ext(def, options)),
|
|
564
|
+
makeRe: (pattern, options = {}) => orig.makeRe(pattern, ext(def, options)),
|
|
565
|
+
braceExpand: (pattern, options = {}) => orig.braceExpand(pattern, ext(def, options)),
|
|
566
|
+
match: (list, pattern, options = {}) => orig.match(list, pattern, ext(def, options)),
|
|
567
|
+
sep: orig.sep,
|
|
568
|
+
GLOBSTAR: exports.GLOBSTAR,
|
|
569
|
+
});
|
|
570
|
+
};
|
|
571
|
+
exports.defaults = defaults;
|
|
572
|
+
exports.minimatch.defaults = exports.defaults;
|
|
573
|
+
// Brace expansion:
|
|
574
|
+
// a{b,c}d -> abd acd
|
|
575
|
+
// a{b,}c -> abc ac
|
|
576
|
+
// a{0..3}d -> a0d a1d a2d a3d
|
|
577
|
+
// a{b,c{d,e}f}g -> abg acdfg acefg
|
|
578
|
+
// a{b,c}d{e,f}g -> abdeg acdeg abdeg abdfg
|
|
579
|
+
//
|
|
580
|
+
// Invalid sets are not expanded.
|
|
581
|
+
// a{2..}b -> a{2..}b
|
|
582
|
+
// a{b}c -> a{b}c
|
|
583
|
+
const braceExpand = (pattern, options = {}) => {
|
|
584
|
+
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
585
|
+
// Thanks to Yeting Li <https://github.com/yetingli> for
|
|
586
|
+
// improving this regexp to avoid a ReDOS vulnerability.
|
|
587
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
588
|
+
// shortcut. no need to expand.
|
|
589
|
+
return [pattern];
|
|
590
|
+
}
|
|
591
|
+
return (0, brace_expansion_1.default)(pattern);
|
|
592
|
+
};
|
|
593
|
+
exports.braceExpand = braceExpand;
|
|
594
|
+
exports.minimatch.braceExpand = exports.braceExpand;
|
|
595
|
+
// parse a component of the expanded set.
|
|
596
|
+
// At this point, no pattern may contain "/" in it
|
|
597
|
+
// so we're going to return a 2d array, where each entry is the full
|
|
598
|
+
// pattern, split on '/', and then turned into a regular expression.
|
|
599
|
+
// A regexp is made at the end which joins each array with an
|
|
600
|
+
// escaped /, and another full one which joins each regexp with |.
|
|
601
|
+
//
|
|
602
|
+
// Following the lead of Bash 4.1, note that "**" only has special meaning
|
|
603
|
+
// when it is the *only* thing in a path portion. Otherwise, any series
|
|
604
|
+
// of * is equivalent to a single *. Globstar behavior is enabled by
|
|
605
|
+
// default, and can be disabled by setting options.noglobstar.
|
|
606
|
+
const makeRe = (pattern, options = {}) => new Minimatch(pattern, options).makeRe();
|
|
607
|
+
exports.makeRe = makeRe;
|
|
608
|
+
exports.minimatch.makeRe = exports.makeRe;
|
|
609
|
+
const match = (list, pattern, options = {}) => {
|
|
610
|
+
const mm = new Minimatch(pattern, options);
|
|
611
|
+
list = list.filter(f => mm.match(f));
|
|
612
|
+
if (mm.options.nonull && !list.length) {
|
|
613
|
+
list.push(pattern);
|
|
614
|
+
}
|
|
615
|
+
return list;
|
|
616
|
+
};
|
|
617
|
+
exports.match = match;
|
|
618
|
+
exports.minimatch.match = exports.match;
|
|
619
|
+
// replace stuff like \* with *
|
|
620
|
+
const globMagic = /[?*]|[+@!]\(.*?\)|\[|\]/;
|
|
621
|
+
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
622
|
+
class Minimatch {
|
|
623
|
+
options;
|
|
624
|
+
set;
|
|
625
|
+
pattern;
|
|
626
|
+
windowsPathsNoEscape;
|
|
627
|
+
nonegate;
|
|
628
|
+
negate;
|
|
629
|
+
comment;
|
|
630
|
+
empty;
|
|
631
|
+
preserveMultipleSlashes;
|
|
632
|
+
partial;
|
|
633
|
+
globSet;
|
|
634
|
+
globParts;
|
|
635
|
+
nocase;
|
|
636
|
+
isWindows;
|
|
637
|
+
platform;
|
|
638
|
+
windowsNoMagicRoot;
|
|
639
|
+
regexp;
|
|
640
|
+
constructor(pattern, options = {}) {
|
|
641
|
+
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
642
|
+
options = options || {};
|
|
643
|
+
this.options = options;
|
|
644
|
+
this.pattern = pattern;
|
|
645
|
+
this.platform = options.platform || defaultPlatform;
|
|
646
|
+
this.isWindows = this.platform === 'win32';
|
|
647
|
+
this.windowsPathsNoEscape =
|
|
648
|
+
!!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
|
|
649
|
+
if (this.windowsPathsNoEscape) {
|
|
650
|
+
this.pattern = this.pattern.replace(/\\/g, '/');
|
|
651
|
+
}
|
|
652
|
+
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
653
|
+
this.regexp = null;
|
|
654
|
+
this.negate = false;
|
|
655
|
+
this.nonegate = !!options.nonegate;
|
|
656
|
+
this.comment = false;
|
|
657
|
+
this.empty = false;
|
|
658
|
+
this.partial = !!options.partial;
|
|
659
|
+
this.nocase = !!this.options.nocase;
|
|
660
|
+
this.windowsNoMagicRoot =
|
|
661
|
+
options.windowsNoMagicRoot !== undefined
|
|
662
|
+
? options.windowsNoMagicRoot
|
|
663
|
+
: !!(this.isWindows && this.nocase);
|
|
664
|
+
this.globSet = [];
|
|
665
|
+
this.globParts = [];
|
|
666
|
+
this.set = [];
|
|
667
|
+
// make the set of regexps etc.
|
|
668
|
+
this.make();
|
|
669
|
+
}
|
|
670
|
+
hasMagic() {
|
|
671
|
+
if (this.options.magicalBraces && this.set.length > 1) {
|
|
672
|
+
return true;
|
|
673
|
+
}
|
|
674
|
+
for (const pattern of this.set) {
|
|
675
|
+
for (const part of pattern) {
|
|
676
|
+
if (typeof part !== 'string')
|
|
677
|
+
return true;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
return false;
|
|
681
|
+
}
|
|
682
|
+
debug(..._) { }
|
|
683
|
+
make() {
|
|
684
|
+
const pattern = this.pattern;
|
|
685
|
+
const options = this.options;
|
|
686
|
+
// empty patterns and comments match nothing.
|
|
687
|
+
if (!options.nocomment && pattern.charAt(0) === '#') {
|
|
688
|
+
this.comment = true;
|
|
689
|
+
return;
|
|
690
|
+
}
|
|
691
|
+
if (!pattern) {
|
|
692
|
+
this.empty = true;
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
// step 1: figure out negation, etc.
|
|
696
|
+
this.parseNegate();
|
|
697
|
+
// step 2: expand braces
|
|
698
|
+
this.globSet = [...new Set(this.braceExpand())];
|
|
699
|
+
if (options.debug) {
|
|
700
|
+
this.debug = (...args) => console.error(...args);
|
|
701
|
+
}
|
|
702
|
+
this.debug(this.pattern, this.globSet);
|
|
703
|
+
// step 3: now we have a set, so turn each one into a series of
|
|
704
|
+
// path-portion matching patterns.
|
|
705
|
+
// These will be regexps, except in the case of "**", which is
|
|
706
|
+
// set to the GLOBSTAR object for globstar behavior,
|
|
707
|
+
// and will not contain any / characters
|
|
708
|
+
//
|
|
709
|
+
// First, we preprocess to make the glob pattern sets a bit simpler
|
|
710
|
+
// and deduped. There are some perf-killing patterns that can cause
|
|
711
|
+
// problems with a glob walk, but we can simplify them down a bit.
|
|
712
|
+
const rawGlobParts = this.globSet.map(s => this.slashSplit(s));
|
|
713
|
+
this.globParts = this.preprocess(rawGlobParts);
|
|
714
|
+
this.debug(this.pattern, this.globParts);
|
|
715
|
+
// glob --> regexps
|
|
716
|
+
let set = this.globParts.map((s, _, __) => {
|
|
717
|
+
if (this.isWindows && this.windowsNoMagicRoot) {
|
|
718
|
+
// check if it's a drive or unc path.
|
|
719
|
+
const isUNC = s[0] === '' &&
|
|
720
|
+
s[1] === '' &&
|
|
721
|
+
(s[2] === '?' || !globMagic.test(s[2])) &&
|
|
722
|
+
!globMagic.test(s[3]);
|
|
723
|
+
const isDrive = /^[a-z]:/i.test(s[0]);
|
|
724
|
+
if (isUNC) {
|
|
725
|
+
return [...s.slice(0, 4), ...s.slice(4).map(ss => this.parse(ss))];
|
|
726
|
+
}
|
|
727
|
+
else if (isDrive) {
|
|
728
|
+
return [s[0], ...s.slice(1).map(ss => this.parse(ss))];
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return s.map(ss => this.parse(ss));
|
|
732
|
+
});
|
|
733
|
+
this.debug(this.pattern, set);
|
|
734
|
+
// filter out everything that didn't compile properly.
|
|
735
|
+
this.set = set.filter(s => s.indexOf(false) === -1);
|
|
736
|
+
// do not treat the ? in UNC paths as magic
|
|
737
|
+
if (this.isWindows) {
|
|
738
|
+
for (let i = 0; i < this.set.length; i++) {
|
|
739
|
+
const p = this.set[i];
|
|
740
|
+
if (p[0] === '' &&
|
|
741
|
+
p[1] === '' &&
|
|
742
|
+
this.globParts[i][2] === '?' &&
|
|
743
|
+
typeof p[3] === 'string' &&
|
|
744
|
+
/^[a-z]:$/i.test(p[3])) {
|
|
745
|
+
p[2] = '?';
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
this.debug(this.pattern, this.set);
|
|
750
|
+
}
|
|
751
|
+
// various transforms to equivalent pattern sets that are
|
|
752
|
+
// faster to process in a filesystem walk. The goal is to
|
|
753
|
+
// eliminate what we can, and push all ** patterns as far
|
|
754
|
+
// to the right as possible, even if it increases the number
|
|
755
|
+
// of patterns that we have to process.
|
|
756
|
+
preprocess(globParts) {
|
|
757
|
+
// if we're not in globstar mode, then turn all ** into *
|
|
758
|
+
if (this.options.noglobstar) {
|
|
759
|
+
for (let i = 0; i < globParts.length; i++) {
|
|
760
|
+
for (let j = 0; j < globParts[i].length; j++) {
|
|
761
|
+
if (globParts[i][j] === '**') {
|
|
762
|
+
globParts[i][j] = '*';
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
const { optimizationLevel = 1 } = this.options;
|
|
768
|
+
if (optimizationLevel >= 2) {
|
|
769
|
+
// aggressive optimization for the purpose of fs walking
|
|
770
|
+
globParts = this.firstPhasePreProcess(globParts);
|
|
771
|
+
globParts = this.secondPhasePreProcess(globParts);
|
|
772
|
+
}
|
|
773
|
+
else if (optimizationLevel >= 1) {
|
|
774
|
+
// just basic optimizations to remove some .. parts
|
|
775
|
+
globParts = this.levelOneOptimize(globParts);
|
|
776
|
+
}
|
|
777
|
+
else {
|
|
778
|
+
globParts = this.adjascentGlobstarOptimize(globParts);
|
|
779
|
+
}
|
|
780
|
+
return globParts;
|
|
781
|
+
}
|
|
782
|
+
// just get rid of adjascent ** portions
|
|
783
|
+
adjascentGlobstarOptimize(globParts) {
|
|
784
|
+
return globParts.map(parts => {
|
|
785
|
+
let gs = -1;
|
|
786
|
+
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
|
|
787
|
+
let i = gs;
|
|
788
|
+
while (parts[i + 1] === '**') {
|
|
789
|
+
i++;
|
|
790
|
+
}
|
|
791
|
+
if (i !== gs) {
|
|
792
|
+
parts.splice(gs, i - gs);
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
return parts;
|
|
796
|
+
});
|
|
797
|
+
}
|
|
798
|
+
// get rid of adjascent ** and resolve .. portions
|
|
799
|
+
levelOneOptimize(globParts) {
|
|
800
|
+
return globParts.map(parts => {
|
|
801
|
+
parts = parts.reduce((set, part) => {
|
|
802
|
+
const prev = set[set.length - 1];
|
|
803
|
+
if (part === '**' && prev === '**') {
|
|
804
|
+
return set;
|
|
805
|
+
}
|
|
806
|
+
if (part === '..') {
|
|
807
|
+
if (prev && prev !== '..' && prev !== '.' && prev !== '**') {
|
|
808
|
+
set.pop();
|
|
809
|
+
return set;
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
set.push(part);
|
|
813
|
+
return set;
|
|
814
|
+
}, []);
|
|
815
|
+
return parts.length === 0 ? [''] : parts;
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
levelTwoFileOptimize(parts) {
|
|
819
|
+
if (!Array.isArray(parts)) {
|
|
820
|
+
parts = this.slashSplit(parts);
|
|
821
|
+
}
|
|
822
|
+
let didSomething = false;
|
|
823
|
+
do {
|
|
824
|
+
didSomething = false;
|
|
825
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
826
|
+
if (!this.preserveMultipleSlashes) {
|
|
827
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
828
|
+
const p = parts[i];
|
|
829
|
+
// don't squeeze out UNC patterns
|
|
830
|
+
if (i === 1 && p === '' && parts[0] === '')
|
|
831
|
+
continue;
|
|
832
|
+
if (p === '.' || p === '') {
|
|
833
|
+
didSomething = true;
|
|
834
|
+
parts.splice(i, 1);
|
|
835
|
+
i--;
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
if (parts[0] === '.' &&
|
|
839
|
+
parts.length === 2 &&
|
|
840
|
+
(parts[1] === '.' || parts[1] === '')) {
|
|
841
|
+
didSomething = true;
|
|
842
|
+
parts.pop();
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
846
|
+
let dd = 0;
|
|
847
|
+
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
848
|
+
const p = parts[dd - 1];
|
|
849
|
+
if (p && p !== '.' && p !== '..' && p !== '**') {
|
|
850
|
+
didSomething = true;
|
|
851
|
+
parts.splice(dd - 1, 2);
|
|
852
|
+
dd -= 2;
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
} while (didSomething);
|
|
856
|
+
return parts.length === 0 ? [''] : parts;
|
|
857
|
+
}
|
|
858
|
+
// First phase: single-pattern processing
|
|
859
|
+
// <pre> is 1 or more portions
|
|
860
|
+
// <rest> is 1 or more portions
|
|
861
|
+
// <p> is any portion other than ., .., '', or **
|
|
862
|
+
// <e> is . or ''
|
|
863
|
+
//
|
|
864
|
+
// **/.. is *brutal* for filesystem walking performance, because
|
|
865
|
+
// it effectively resets the recursive walk each time it occurs,
|
|
866
|
+
// and ** cannot be reduced out by a .. pattern part like a regexp
|
|
867
|
+
// or most strings (other than .., ., and '') can be.
|
|
868
|
+
//
|
|
869
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
870
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
871
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
872
|
+
// **/**/<rest> -> **/<rest>
|
|
873
|
+
//
|
|
874
|
+
// **/*/<rest> -> */**/<rest> <== not valid because ** doesn't follow
|
|
875
|
+
// this WOULD be allowed if ** did follow symlinks, or * didn't
|
|
876
|
+
firstPhasePreProcess(globParts) {
|
|
877
|
+
let didSomething = false;
|
|
878
|
+
do {
|
|
879
|
+
didSomething = false;
|
|
880
|
+
// <pre>/**/../<p>/<p>/<rest> -> {<pre>/../<p>/<p>/<rest>,<pre>/**/<p>/<p>/<rest>}
|
|
881
|
+
for (let parts of globParts) {
|
|
882
|
+
let gs = -1;
|
|
883
|
+
while (-1 !== (gs = parts.indexOf('**', gs + 1))) {
|
|
884
|
+
let gss = gs;
|
|
885
|
+
while (parts[gss + 1] === '**') {
|
|
886
|
+
// <pre>/**/**/<rest> -> <pre>/**/<rest>
|
|
887
|
+
gss++;
|
|
888
|
+
}
|
|
889
|
+
// eg, if gs is 2 and gss is 4, that means we have 3 **
|
|
890
|
+
// parts, and can remove 2 of them.
|
|
891
|
+
if (gss > gs) {
|
|
892
|
+
parts.splice(gs + 1, gss - gs);
|
|
893
|
+
}
|
|
894
|
+
let next = parts[gs + 1];
|
|
895
|
+
const p = parts[gs + 2];
|
|
896
|
+
const p2 = parts[gs + 3];
|
|
897
|
+
if (next !== '..')
|
|
898
|
+
continue;
|
|
899
|
+
if (!p ||
|
|
900
|
+
p === '.' ||
|
|
901
|
+
p === '..' ||
|
|
902
|
+
!p2 ||
|
|
903
|
+
p2 === '.' ||
|
|
904
|
+
p2 === '..') {
|
|
905
|
+
continue;
|
|
906
|
+
}
|
|
907
|
+
didSomething = true;
|
|
908
|
+
// edit parts in place, and push the new one
|
|
909
|
+
parts.splice(gs, 1);
|
|
910
|
+
const other = parts.slice(0);
|
|
911
|
+
other[gs] = '**';
|
|
912
|
+
globParts.push(other);
|
|
913
|
+
gs--;
|
|
914
|
+
}
|
|
915
|
+
// <pre>/<e>/<rest> -> <pre>/<rest>
|
|
916
|
+
if (!this.preserveMultipleSlashes) {
|
|
917
|
+
for (let i = 1; i < parts.length - 1; i++) {
|
|
918
|
+
const p = parts[i];
|
|
919
|
+
// don't squeeze out UNC patterns
|
|
920
|
+
if (i === 1 && p === '' && parts[0] === '')
|
|
921
|
+
continue;
|
|
922
|
+
if (p === '.' || p === '') {
|
|
923
|
+
didSomething = true;
|
|
924
|
+
parts.splice(i, 1);
|
|
925
|
+
i--;
|
|
926
|
+
}
|
|
927
|
+
}
|
|
928
|
+
if (parts[0] === '.' &&
|
|
929
|
+
parts.length === 2 &&
|
|
930
|
+
(parts[1] === '.' || parts[1] === '')) {
|
|
931
|
+
didSomething = true;
|
|
932
|
+
parts.pop();
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
// <pre>/<p>/../<rest> -> <pre>/<rest>
|
|
936
|
+
let dd = 0;
|
|
937
|
+
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
938
|
+
const p = parts[dd - 1];
|
|
939
|
+
if (p && p !== '.' && p !== '..' && p !== '**') {
|
|
940
|
+
didSomething = true;
|
|
941
|
+
const needDot = dd === 1 && parts[dd + 1] === '**';
|
|
942
|
+
const splin = needDot ? ['.'] : [];
|
|
943
|
+
parts.splice(dd - 1, 2, ...splin);
|
|
944
|
+
if (parts.length === 0)
|
|
945
|
+
parts.push('');
|
|
946
|
+
dd -= 2;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
} while (didSomething);
|
|
951
|
+
return globParts;
|
|
952
|
+
}
|
|
953
|
+
// second phase: multi-pattern dedupes
|
|
954
|
+
// {<pre>/*/<rest>,<pre>/<p>/<rest>} -> <pre>/*/<rest>
|
|
955
|
+
// {<pre>/<rest>,<pre>/<rest>} -> <pre>/<rest>
|
|
956
|
+
// {<pre>/**/<rest>,<pre>/<rest>} -> <pre>/**/<rest>
|
|
957
|
+
//
|
|
958
|
+
// {<pre>/**/<rest>,<pre>/**/<p>/<rest>} -> <pre>/**/<rest>
|
|
959
|
+
// ^-- not valid because ** doens't follow symlinks
|
|
960
|
+
secondPhasePreProcess(globParts) {
|
|
961
|
+
for (let i = 0; i < globParts.length - 1; i++) {
|
|
962
|
+
for (let j = i + 1; j < globParts.length; j++) {
|
|
963
|
+
const matched = this.partsMatch(globParts[i], globParts[j], !this.preserveMultipleSlashes);
|
|
964
|
+
if (!matched)
|
|
965
|
+
continue;
|
|
966
|
+
globParts[i] = matched;
|
|
967
|
+
globParts[j] = [];
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
return globParts.filter(gs => gs.length);
|
|
971
|
+
}
|
|
972
|
+
partsMatch(a, b, emptyGSMatch = false) {
|
|
973
|
+
let ai = 0;
|
|
974
|
+
let bi = 0;
|
|
975
|
+
let result = [];
|
|
976
|
+
let which = '';
|
|
977
|
+
while (ai < a.length && bi < b.length) {
|
|
978
|
+
if (a[ai] === b[bi]) {
|
|
979
|
+
result.push(which === 'b' ? b[bi] : a[ai]);
|
|
980
|
+
ai++;
|
|
981
|
+
bi++;
|
|
982
|
+
}
|
|
983
|
+
else if (emptyGSMatch && a[ai] === '**' && b[bi] === a[ai + 1]) {
|
|
984
|
+
result.push(a[ai]);
|
|
985
|
+
ai++;
|
|
986
|
+
}
|
|
987
|
+
else if (emptyGSMatch && b[bi] === '**' && a[ai] === b[bi + 1]) {
|
|
988
|
+
result.push(b[bi]);
|
|
989
|
+
bi++;
|
|
990
|
+
}
|
|
991
|
+
else if (a[ai] === '*' &&
|
|
992
|
+
b[bi] &&
|
|
993
|
+
(this.options.dot || !b[bi].startsWith('.')) &&
|
|
994
|
+
b[bi] !== '**') {
|
|
995
|
+
if (which === 'b')
|
|
996
|
+
return false;
|
|
997
|
+
which = 'a';
|
|
998
|
+
result.push(a[ai]);
|
|
999
|
+
ai++;
|
|
1000
|
+
bi++;
|
|
1001
|
+
}
|
|
1002
|
+
else if (b[bi] === '*' &&
|
|
1003
|
+
a[ai] &&
|
|
1004
|
+
(this.options.dot || !a[ai].startsWith('.')) &&
|
|
1005
|
+
a[ai] !== '**') {
|
|
1006
|
+
if (which === 'a')
|
|
1007
|
+
return false;
|
|
1008
|
+
which = 'b';
|
|
1009
|
+
result.push(b[bi]);
|
|
1010
|
+
ai++;
|
|
1011
|
+
bi++;
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
return false;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
// if we fall out of the loop, it means they two are identical
|
|
1018
|
+
// as long as their lengths match
|
|
1019
|
+
return a.length === b.length && result;
|
|
1020
|
+
}
|
|
1021
|
+
parseNegate() {
|
|
1022
|
+
if (this.nonegate)
|
|
1023
|
+
return;
|
|
1024
|
+
const pattern = this.pattern;
|
|
1025
|
+
let negate = false;
|
|
1026
|
+
let negateOffset = 0;
|
|
1027
|
+
for (let i = 0; i < pattern.length && pattern.charAt(i) === '!'; i++) {
|
|
1028
|
+
negate = !negate;
|
|
1029
|
+
negateOffset++;
|
|
1030
|
+
}
|
|
1031
|
+
if (negateOffset)
|
|
1032
|
+
this.pattern = pattern.slice(negateOffset);
|
|
1033
|
+
this.negate = negate;
|
|
1034
|
+
}
|
|
1035
|
+
// set partial to true to test if, for example,
|
|
1036
|
+
// "/a/b" matches the start of "/*/b/*/d"
|
|
1037
|
+
// Partial means, if you run out of file before you run
|
|
1038
|
+
// out of pattern, then that's fine, as long as all
|
|
1039
|
+
// the parts match.
|
|
1040
|
+
matchOne(file, pattern, partial = false) {
|
|
1041
|
+
const options = this.options;
|
|
1042
|
+
// UNC paths like //?/X:/... can match X:/... and vice versa
|
|
1043
|
+
// Drive letters in absolute drive or unc paths are always compared
|
|
1044
|
+
// case-insensitively.
|
|
1045
|
+
if (this.isWindows) {
|
|
1046
|
+
const fileDrive = typeof file[0] === 'string' && /^[a-z]:$/i.test(file[0]);
|
|
1047
|
+
const fileUNC = !fileDrive &&
|
|
1048
|
+
file[0] === '' &&
|
|
1049
|
+
file[1] === '' &&
|
|
1050
|
+
file[2] === '?' &&
|
|
1051
|
+
/^[a-z]:$/i.test(file[3]);
|
|
1052
|
+
const patternDrive = typeof pattern[0] === 'string' && /^[a-z]:$/i.test(pattern[0]);
|
|
1053
|
+
const patternUNC = !patternDrive &&
|
|
1054
|
+
pattern[0] === '' &&
|
|
1055
|
+
pattern[1] === '' &&
|
|
1056
|
+
pattern[2] === '?' &&
|
|
1057
|
+
typeof pattern[3] === 'string' &&
|
|
1058
|
+
/^[a-z]:$/i.test(pattern[3]);
|
|
1059
|
+
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
|
|
1060
|
+
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
|
|
1061
|
+
if (typeof fdi === 'number' && typeof pdi === 'number') {
|
|
1062
|
+
const [fd, pd] = [file[fdi], pattern[pdi]];
|
|
1063
|
+
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
1064
|
+
pattern[pdi] = fd;
|
|
1065
|
+
if (pdi > fdi) {
|
|
1066
|
+
pattern = pattern.slice(pdi);
|
|
1067
|
+
}
|
|
1068
|
+
else if (fdi > pdi) {
|
|
1069
|
+
file = file.slice(fdi);
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
// resolve and reduce . and .. portions in the file as well.
|
|
1075
|
+
// dont' need to do the second phase, because it's only one string[]
|
|
1076
|
+
const { optimizationLevel = 1 } = this.options;
|
|
1077
|
+
if (optimizationLevel >= 2) {
|
|
1078
|
+
file = this.levelTwoFileOptimize(file);
|
|
1079
|
+
}
|
|
1080
|
+
this.debug('matchOne', this, { file, pattern });
|
|
1081
|
+
this.debug('matchOne', file.length, pattern.length);
|
|
1082
|
+
for (var fi = 0, pi = 0, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
|
|
1083
|
+
this.debug('matchOne loop');
|
|
1084
|
+
var p = pattern[pi];
|
|
1085
|
+
var f = file[fi];
|
|
1086
|
+
this.debug(pattern, p, f);
|
|
1087
|
+
// should be impossible.
|
|
1088
|
+
// some invalid regexp stuff in the set.
|
|
1089
|
+
/* c8 ignore start */
|
|
1090
|
+
if (p === false) {
|
|
1091
|
+
return false;
|
|
1092
|
+
}
|
|
1093
|
+
/* c8 ignore stop */
|
|
1094
|
+
if (p === exports.GLOBSTAR) {
|
|
1095
|
+
this.debug('GLOBSTAR', [pattern, p, f]);
|
|
1096
|
+
// "**"
|
|
1097
|
+
// a/**/b/**/c would match the following:
|
|
1098
|
+
// a/b/x/y/z/c
|
|
1099
|
+
// a/x/y/z/b/c
|
|
1100
|
+
// a/b/x/b/x/c
|
|
1101
|
+
// a/b/c
|
|
1102
|
+
// To do this, take the rest of the pattern after
|
|
1103
|
+
// the **, and see if it would match the file remainder.
|
|
1104
|
+
// If so, return success.
|
|
1105
|
+
// If not, the ** "swallows" a segment, and try again.
|
|
1106
|
+
// This is recursively awful.
|
|
1107
|
+
//
|
|
1108
|
+
// a/**/b/**/c matching a/b/x/y/z/c
|
|
1109
|
+
// - a matches a
|
|
1110
|
+
// - doublestar
|
|
1111
|
+
// - matchOne(b/x/y/z/c, b/**/c)
|
|
1112
|
+
// - b matches b
|
|
1113
|
+
// - doublestar
|
|
1114
|
+
// - matchOne(x/y/z/c, c) -> no
|
|
1115
|
+
// - matchOne(y/z/c, c) -> no
|
|
1116
|
+
// - matchOne(z/c, c) -> no
|
|
1117
|
+
// - matchOne(c, c) yes, hit
|
|
1118
|
+
var fr = fi;
|
|
1119
|
+
var pr = pi + 1;
|
|
1120
|
+
if (pr === pl) {
|
|
1121
|
+
this.debug('** at the end');
|
|
1122
|
+
// a ** at the end will just swallow the rest.
|
|
1123
|
+
// We have found a match.
|
|
1124
|
+
// however, it will not swallow /.x, unless
|
|
1125
|
+
// options.dot is set.
|
|
1126
|
+
// . and .. are *never* matched by **, for explosively
|
|
1127
|
+
// exponential reasons.
|
|
1128
|
+
for (; fi < fl; fi++) {
|
|
1129
|
+
if (file[fi] === '.' ||
|
|
1130
|
+
file[fi] === '..' ||
|
|
1131
|
+
(!options.dot && file[fi].charAt(0) === '.'))
|
|
1132
|
+
return false;
|
|
1133
|
+
}
|
|
1134
|
+
return true;
|
|
1135
|
+
}
|
|
1136
|
+
// ok, let's see if we can swallow whatever we can.
|
|
1137
|
+
while (fr < fl) {
|
|
1138
|
+
var swallowee = file[fr];
|
|
1139
|
+
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
|
1140
|
+
// XXX remove this slice. Just pass the start index.
|
|
1141
|
+
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
1142
|
+
this.debug('globstar found match!', fr, fl, swallowee);
|
|
1143
|
+
// found a match.
|
|
1144
|
+
return true;
|
|
1145
|
+
}
|
|
1146
|
+
else {
|
|
1147
|
+
// can't swallow "." or ".." ever.
|
|
1148
|
+
// can only swallow ".foo" when explicitly asked.
|
|
1149
|
+
if (swallowee === '.' ||
|
|
1150
|
+
swallowee === '..' ||
|
|
1151
|
+
(!options.dot && swallowee.charAt(0) === '.')) {
|
|
1152
|
+
this.debug('dot detected!', file, fr, pattern, pr);
|
|
1153
|
+
break;
|
|
1154
|
+
}
|
|
1155
|
+
// ** swallows a segment, and continue.
|
|
1156
|
+
this.debug('globstar swallow a segment, and continue');
|
|
1157
|
+
fr++;
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
// no match was found.
|
|
1161
|
+
// However, in partial mode, we can't say this is necessarily over.
|
|
1162
|
+
/* c8 ignore start */
|
|
1163
|
+
if (partial) {
|
|
1164
|
+
// ran out of file
|
|
1165
|
+
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
|
1166
|
+
if (fr === fl) {
|
|
1167
|
+
return true;
|
|
1168
|
+
}
|
|
1169
|
+
}
|
|
1170
|
+
/* c8 ignore stop */
|
|
1171
|
+
return false;
|
|
1172
|
+
}
|
|
1173
|
+
// something other than **
|
|
1174
|
+
// non-magic patterns just have to match exactly
|
|
1175
|
+
// patterns with magic have been turned into regexps.
|
|
1176
|
+
let hit;
|
|
1177
|
+
if (typeof p === 'string') {
|
|
1178
|
+
hit = f === p;
|
|
1179
|
+
this.debug('string match', p, f, hit);
|
|
1180
|
+
}
|
|
1181
|
+
else {
|
|
1182
|
+
hit = p.test(f);
|
|
1183
|
+
this.debug('pattern match', p, f, hit);
|
|
1184
|
+
}
|
|
1185
|
+
if (!hit)
|
|
1186
|
+
return false;
|
|
1187
|
+
}
|
|
1188
|
+
// Note: ending in / means that we'll get a final ""
|
|
1189
|
+
// at the end of the pattern. This can only match a
|
|
1190
|
+
// corresponding "" at the end of the file.
|
|
1191
|
+
// If the file ends in /, then it can only match a
|
|
1192
|
+
// a pattern that ends in /, unless the pattern just
|
|
1193
|
+
// doesn't have any more for it. But, a/b/ should *not*
|
|
1194
|
+
// match "a/b/*", even though "" matches against the
|
|
1195
|
+
// [^/]*? pattern, except in partial mode, where it might
|
|
1196
|
+
// simply not be reached yet.
|
|
1197
|
+
// However, a/b/ should still satisfy a/*
|
|
1198
|
+
// now either we fell off the end of the pattern, or we're done.
|
|
1199
|
+
if (fi === fl && pi === pl) {
|
|
1200
|
+
// ran out of pattern and filename at the same time.
|
|
1201
|
+
// an exact hit!
|
|
1202
|
+
return true;
|
|
1203
|
+
}
|
|
1204
|
+
else if (fi === fl) {
|
|
1205
|
+
// ran out of file, but still had pattern left.
|
|
1206
|
+
// this is ok if we're doing the match as part of
|
|
1207
|
+
// a glob fs traversal.
|
|
1208
|
+
return partial;
|
|
1209
|
+
}
|
|
1210
|
+
else if (pi === pl) {
|
|
1211
|
+
// ran out of pattern, still have file left.
|
|
1212
|
+
// this is only acceptable if we're on the very last
|
|
1213
|
+
// empty segment of a file with a trailing slash.
|
|
1214
|
+
// a/* should match a/b/
|
|
1215
|
+
return fi === fl - 1 && file[fi] === '';
|
|
1216
|
+
/* c8 ignore start */
|
|
1217
|
+
}
|
|
1218
|
+
else {
|
|
1219
|
+
// should be unreachable.
|
|
1220
|
+
throw new Error('wtf?');
|
|
1221
|
+
}
|
|
1222
|
+
/* c8 ignore stop */
|
|
1223
|
+
}
|
|
1224
|
+
braceExpand() {
|
|
1225
|
+
return (0, exports.braceExpand)(this.pattern, this.options);
|
|
1226
|
+
}
|
|
1227
|
+
parse(pattern) {
|
|
1228
|
+
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
1229
|
+
const options = this.options;
|
|
1230
|
+
// shortcuts
|
|
1231
|
+
if (pattern === '**')
|
|
1232
|
+
return exports.GLOBSTAR;
|
|
1233
|
+
if (pattern === '')
|
|
1234
|
+
return '';
|
|
1235
|
+
// far and away, the most common glob pattern parts are
|
|
1236
|
+
// *, *.*, and *.<ext> Add a fast check method for those.
|
|
1237
|
+
let m;
|
|
1238
|
+
let fastTest = null;
|
|
1239
|
+
if ((m = pattern.match(starRE))) {
|
|
1240
|
+
fastTest = options.dot ? starTestDot : starTest;
|
|
1241
|
+
}
|
|
1242
|
+
else if ((m = pattern.match(starDotExtRE))) {
|
|
1243
|
+
fastTest = (options.nocase
|
|
1244
|
+
? options.dot
|
|
1245
|
+
? starDotExtTestNocaseDot
|
|
1246
|
+
: starDotExtTestNocase
|
|
1247
|
+
: options.dot
|
|
1248
|
+
? starDotExtTestDot
|
|
1249
|
+
: starDotExtTest)(m[1]);
|
|
1250
|
+
}
|
|
1251
|
+
else if ((m = pattern.match(qmarksRE))) {
|
|
1252
|
+
fastTest = (options.nocase
|
|
1253
|
+
? options.dot
|
|
1254
|
+
? qmarksTestNocaseDot
|
|
1255
|
+
: qmarksTestNocase
|
|
1256
|
+
: options.dot
|
|
1257
|
+
? qmarksTestDot
|
|
1258
|
+
: qmarksTest)(m);
|
|
1259
|
+
}
|
|
1260
|
+
else if ((m = pattern.match(starDotStarRE))) {
|
|
1261
|
+
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
|
|
1262
|
+
}
|
|
1263
|
+
else if ((m = pattern.match(dotStarRE))) {
|
|
1264
|
+
fastTest = dotStarTest;
|
|
1265
|
+
}
|
|
1266
|
+
const re = ast_js_1.AST.fromGlob(pattern, this.options).toMMPattern();
|
|
1267
|
+
return fastTest ? Object.assign(re, { test: fastTest }) : re;
|
|
1268
|
+
}
|
|
1269
|
+
makeRe() {
|
|
1270
|
+
if (this.regexp || this.regexp === false)
|
|
1271
|
+
return this.regexp;
|
|
1272
|
+
// at this point, this.set is a 2d array of partial
|
|
1273
|
+
// pattern strings, or "**".
|
|
1274
|
+
//
|
|
1275
|
+
// It's better to use .match(). This function shouldn't
|
|
1276
|
+
// be used, really, but it's pretty convenient sometimes,
|
|
1277
|
+
// when you just want to work with a regex.
|
|
1278
|
+
const set = this.set;
|
|
1279
|
+
if (!set.length) {
|
|
1280
|
+
this.regexp = false;
|
|
1281
|
+
return this.regexp;
|
|
1282
|
+
}
|
|
1283
|
+
const options = this.options;
|
|
1284
|
+
const twoStar = options.noglobstar
|
|
1285
|
+
? star
|
|
1286
|
+
: options.dot
|
|
1287
|
+
? twoStarDot
|
|
1288
|
+
: twoStarNoDot;
|
|
1289
|
+
const flags = new Set(options.nocase ? ['i'] : []);
|
|
1290
|
+
// regexpify non-globstar patterns
|
|
1291
|
+
// if ** is only item, then we just do one twoStar
|
|
1292
|
+
// if ** is first, and there are more, prepend (\/|twoStar\/)? to next
|
|
1293
|
+
// if ** is last, append (\/twoStar|) to previous
|
|
1294
|
+
// if ** is in the middle, append (\/|\/twoStar\/) to previous
|
|
1295
|
+
// then filter out GLOBSTAR symbols
|
|
1296
|
+
let re = set
|
|
1297
|
+
.map(pattern => {
|
|
1298
|
+
const pp = pattern.map(p => {
|
|
1299
|
+
if (p instanceof RegExp) {
|
|
1300
|
+
for (const f of p.flags.split(''))
|
|
1301
|
+
flags.add(f);
|
|
1302
|
+
}
|
|
1303
|
+
return typeof p === 'string'
|
|
1304
|
+
? regExpEscape(p)
|
|
1305
|
+
: p === exports.GLOBSTAR
|
|
1306
|
+
? exports.GLOBSTAR
|
|
1307
|
+
: p._src;
|
|
1308
|
+
});
|
|
1309
|
+
pp.forEach((p, i) => {
|
|
1310
|
+
const next = pp[i + 1];
|
|
1311
|
+
const prev = pp[i - 1];
|
|
1312
|
+
if (p !== exports.GLOBSTAR || prev === exports.GLOBSTAR) {
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (prev === undefined) {
|
|
1316
|
+
if (next !== undefined && next !== exports.GLOBSTAR) {
|
|
1317
|
+
pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
1318
|
+
}
|
|
1319
|
+
else {
|
|
1320
|
+
pp[i] = twoStar;
|
|
1321
|
+
}
|
|
1322
|
+
}
|
|
1323
|
+
else if (next === undefined) {
|
|
1324
|
+
pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
|
|
1325
|
+
}
|
|
1326
|
+
else if (next !== exports.GLOBSTAR) {
|
|
1327
|
+
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
1328
|
+
pp[i + 1] = exports.GLOBSTAR;
|
|
1329
|
+
}
|
|
1330
|
+
});
|
|
1331
|
+
return pp.filter(p => p !== exports.GLOBSTAR).join('/');
|
|
1332
|
+
})
|
|
1333
|
+
.join('|');
|
|
1334
|
+
// need to wrap in parens if we had more than one thing with |,
|
|
1335
|
+
// otherwise only the first will be anchored to ^ and the last to $
|
|
1336
|
+
const [open, close] = set.length > 1 ? ['(?:', ')'] : ['', ''];
|
|
1337
|
+
// must match entire pattern
|
|
1338
|
+
// ending in a * or ** will make it less strict.
|
|
1339
|
+
re = '^' + open + re + close + '$';
|
|
1340
|
+
// can match anything, as long as it's not this.
|
|
1341
|
+
if (this.negate)
|
|
1342
|
+
re = '^(?!' + re + ').+$';
|
|
1343
|
+
try {
|
|
1344
|
+
this.regexp = new RegExp(re, [...flags].join(''));
|
|
1345
|
+
/* c8 ignore start */
|
|
1346
|
+
}
|
|
1347
|
+
catch (ex) {
|
|
1348
|
+
// should be impossible
|
|
1349
|
+
this.regexp = false;
|
|
1350
|
+
}
|
|
1351
|
+
/* c8 ignore stop */
|
|
1352
|
+
return this.regexp;
|
|
1353
|
+
}
|
|
1354
|
+
slashSplit(p) {
|
|
1355
|
+
// if p starts with // on windows, we preserve that
|
|
1356
|
+
// so that UNC paths aren't broken. Otherwise, any number of
|
|
1357
|
+
// / characters are coalesced into one, unless
|
|
1358
|
+
// preserveMultipleSlashes is set to true.
|
|
1359
|
+
if (this.preserveMultipleSlashes) {
|
|
1360
|
+
return p.split('/');
|
|
1361
|
+
}
|
|
1362
|
+
else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
|
|
1363
|
+
// add an extra '' for the one we lose
|
|
1364
|
+
return ['', ...p.split(/\/+/)];
|
|
1365
|
+
}
|
|
1366
|
+
else {
|
|
1367
|
+
return p.split(/\/+/);
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
match(f, partial = this.partial) {
|
|
1371
|
+
this.debug('match', f, this.pattern);
|
|
1372
|
+
// short-circuit in the case of busted things.
|
|
1373
|
+
// comments, etc.
|
|
1374
|
+
if (this.comment) {
|
|
1375
|
+
return false;
|
|
1376
|
+
}
|
|
1377
|
+
if (this.empty) {
|
|
1378
|
+
return f === '';
|
|
1379
|
+
}
|
|
1380
|
+
if (f === '/' && partial) {
|
|
1381
|
+
return true;
|
|
1382
|
+
}
|
|
1383
|
+
const options = this.options;
|
|
1384
|
+
// windows: need to use /, not \
|
|
1385
|
+
if (this.isWindows) {
|
|
1386
|
+
f = f.split('\\').join('/');
|
|
1387
|
+
}
|
|
1388
|
+
// treat the test path as a set of pathparts.
|
|
1389
|
+
const ff = this.slashSplit(f);
|
|
1390
|
+
this.debug(this.pattern, 'split', ff);
|
|
1391
|
+
// just ONE of the pattern sets in this.set needs to match
|
|
1392
|
+
// in order for it to be valid. If negating, then just one
|
|
1393
|
+
// match means that we have failed.
|
|
1394
|
+
// Either way, return on the first hit.
|
|
1395
|
+
const set = this.set;
|
|
1396
|
+
this.debug(this.pattern, 'set', set);
|
|
1397
|
+
// Find the basename of the path by looking for the last non-empty segment
|
|
1398
|
+
let filename = ff[ff.length - 1];
|
|
1399
|
+
if (!filename) {
|
|
1400
|
+
for (let i = ff.length - 2; !filename && i >= 0; i--) {
|
|
1401
|
+
filename = ff[i];
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
for (let i = 0; i < set.length; i++) {
|
|
1405
|
+
const pattern = set[i];
|
|
1406
|
+
let file = ff;
|
|
1407
|
+
if (options.matchBase && pattern.length === 1) {
|
|
1408
|
+
file = [filename];
|
|
1409
|
+
}
|
|
1410
|
+
const hit = this.matchOne(file, pattern, partial);
|
|
1411
|
+
if (hit) {
|
|
1412
|
+
if (options.flipNegate) {
|
|
1413
|
+
return true;
|
|
1414
|
+
}
|
|
1415
|
+
return !this.negate;
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
// didn't get any hits. this is success if it's a negative
|
|
1419
|
+
// pattern, failure otherwise.
|
|
1420
|
+
if (options.flipNegate) {
|
|
1421
|
+
return false;
|
|
1422
|
+
}
|
|
1423
|
+
return this.negate;
|
|
1424
|
+
}
|
|
1425
|
+
static defaults(def) {
|
|
1426
|
+
return exports.minimatch.defaults(def).Minimatch;
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1429
|
+
exports.Minimatch = Minimatch;
|
|
1430
|
+
/* c8 ignore start */
|
|
1431
|
+
var ast_js_2 = __webpack_require__(10);
|
|
1432
|
+
Object.defineProperty(exports, "AST", ({ enumerable: true, get: function () { return ast_js_2.AST; } }));
|
|
1433
|
+
var escape_js_2 = __webpack_require__(13);
|
|
1434
|
+
Object.defineProperty(exports, "escape", ({ enumerable: true, get: function () { return escape_js_2.escape; } }));
|
|
1435
|
+
var unescape_js_2 = __webpack_require__(12);
|
|
1436
|
+
Object.defineProperty(exports, "unescape", ({ enumerable: true, get: function () { return unescape_js_2.unescape; } }));
|
|
1437
|
+
/* c8 ignore stop */
|
|
1438
|
+
exports.minimatch.AST = ast_js_1.AST;
|
|
1439
|
+
exports.minimatch.Minimatch = Minimatch;
|
|
1440
|
+
exports.minimatch.escape = escape_js_1.escape;
|
|
1441
|
+
exports.minimatch.unescape = unescape_js_1.unescape;
|
|
1442
|
+
//# sourceMappingURL=index.js.map
|
|
1443
|
+
|
|
1444
|
+
/***/ }),
|
|
1445
|
+
/* 7 */
|
|
1446
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
1447
|
+
|
|
1448
|
+
var balanced = __webpack_require__(8);
|
|
1449
|
+
|
|
1450
|
+
module.exports = expandTop;
|
|
1451
|
+
|
|
1452
|
+
var escSlash = '\0SLASH'+Math.random()+'\0';
|
|
1453
|
+
var escOpen = '\0OPEN'+Math.random()+'\0';
|
|
1454
|
+
var escClose = '\0CLOSE'+Math.random()+'\0';
|
|
1455
|
+
var escComma = '\0COMMA'+Math.random()+'\0';
|
|
1456
|
+
var escPeriod = '\0PERIOD'+Math.random()+'\0';
|
|
1457
|
+
|
|
1458
|
+
function numeric(str) {
|
|
1459
|
+
return parseInt(str, 10) == str
|
|
1460
|
+
? parseInt(str, 10)
|
|
1461
|
+
: str.charCodeAt(0);
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
function escapeBraces(str) {
|
|
1465
|
+
return str.split('\\\\').join(escSlash)
|
|
1466
|
+
.split('\\{').join(escOpen)
|
|
1467
|
+
.split('\\}').join(escClose)
|
|
1468
|
+
.split('\\,').join(escComma)
|
|
1469
|
+
.split('\\.').join(escPeriod);
|
|
1470
|
+
}
|
|
1471
|
+
|
|
1472
|
+
function unescapeBraces(str) {
|
|
1473
|
+
return str.split(escSlash).join('\\')
|
|
1474
|
+
.split(escOpen).join('{')
|
|
1475
|
+
.split(escClose).join('}')
|
|
1476
|
+
.split(escComma).join(',')
|
|
1477
|
+
.split(escPeriod).join('.');
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
|
|
1481
|
+
// Basically just str.split(","), but handling cases
|
|
1482
|
+
// where we have nested braced sections, which should be
|
|
1483
|
+
// treated as individual members, like {a,{b,c},d}
|
|
1484
|
+
function parseCommaParts(str) {
|
|
1485
|
+
if (!str)
|
|
1486
|
+
return [''];
|
|
1487
|
+
|
|
1488
|
+
var parts = [];
|
|
1489
|
+
var m = balanced('{', '}', str);
|
|
1490
|
+
|
|
1491
|
+
if (!m)
|
|
1492
|
+
return str.split(',');
|
|
1493
|
+
|
|
1494
|
+
var pre = m.pre;
|
|
1495
|
+
var body = m.body;
|
|
1496
|
+
var post = m.post;
|
|
1497
|
+
var p = pre.split(',');
|
|
1498
|
+
|
|
1499
|
+
p[p.length-1] += '{' + body + '}';
|
|
1500
|
+
var postParts = parseCommaParts(post);
|
|
1501
|
+
if (post.length) {
|
|
1502
|
+
p[p.length-1] += postParts.shift();
|
|
1503
|
+
p.push.apply(p, postParts);
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
parts.push.apply(parts, p);
|
|
1507
|
+
|
|
1508
|
+
return parts;
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
function expandTop(str) {
|
|
1512
|
+
if (!str)
|
|
1513
|
+
return [];
|
|
1514
|
+
|
|
1515
|
+
// I don't know why Bash 4.3 does this, but it does.
|
|
1516
|
+
// Anything starting with {} will have the first two bytes preserved
|
|
1517
|
+
// but *only* at the top level, so {},a}b will not expand to anything,
|
|
1518
|
+
// but a{},b}c will be expanded to [a}c,abc].
|
|
1519
|
+
// One could argue that this is a bug in Bash, but since the goal of
|
|
1520
|
+
// this module is to match Bash's rules, we escape a leading {}
|
|
1521
|
+
if (str.substr(0, 2) === '{}') {
|
|
1522
|
+
str = '\\{\\}' + str.substr(2);
|
|
1523
|
+
}
|
|
1524
|
+
|
|
1525
|
+
return expand(escapeBraces(str), true).map(unescapeBraces);
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
function embrace(str) {
|
|
1529
|
+
return '{' + str + '}';
|
|
1530
|
+
}
|
|
1531
|
+
function isPadded(el) {
|
|
1532
|
+
return /^-?0\d/.test(el);
|
|
1533
|
+
}
|
|
1534
|
+
|
|
1535
|
+
function lte(i, y) {
|
|
1536
|
+
return i <= y;
|
|
1537
|
+
}
|
|
1538
|
+
function gte(i, y) {
|
|
1539
|
+
return i >= y;
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
function expand(str, isTop) {
|
|
1543
|
+
var expansions = [];
|
|
1544
|
+
|
|
1545
|
+
var m = balanced('{', '}', str);
|
|
1546
|
+
if (!m) return [str];
|
|
1547
|
+
|
|
1548
|
+
// no need to expand pre, since it is guaranteed to be free of brace-sets
|
|
1549
|
+
var pre = m.pre;
|
|
1550
|
+
var post = m.post.length
|
|
1551
|
+
? expand(m.post, false)
|
|
1552
|
+
: [''];
|
|
1553
|
+
|
|
1554
|
+
if (/\$$/.test(m.pre)) {
|
|
1555
|
+
for (var k = 0; k < post.length; k++) {
|
|
1556
|
+
var expansion = pre+ '{' + m.body + '}' + post[k];
|
|
1557
|
+
expansions.push(expansion);
|
|
1558
|
+
}
|
|
1559
|
+
} else {
|
|
1560
|
+
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
1561
|
+
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
1562
|
+
var isSequence = isNumericSequence || isAlphaSequence;
|
|
1563
|
+
var isOptions = m.body.indexOf(',') >= 0;
|
|
1564
|
+
if (!isSequence && !isOptions) {
|
|
1565
|
+
// {a},b}
|
|
1566
|
+
if (m.post.match(/,.*\}/)) {
|
|
1567
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
1568
|
+
return expand(str);
|
|
1569
|
+
}
|
|
1570
|
+
return [str];
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
var n;
|
|
1574
|
+
if (isSequence) {
|
|
1575
|
+
n = m.body.split(/\.\./);
|
|
1576
|
+
} else {
|
|
1577
|
+
n = parseCommaParts(m.body);
|
|
1578
|
+
if (n.length === 1) {
|
|
1579
|
+
// x{{a,b}}y ==> x{a}y x{b}y
|
|
1580
|
+
n = expand(n[0], false).map(embrace);
|
|
1581
|
+
if (n.length === 1) {
|
|
1582
|
+
return post.map(function(p) {
|
|
1583
|
+
return m.pre + n[0] + p;
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// at this point, n is the parts, and we know it's not a comma set
|
|
1590
|
+
// with a single entry.
|
|
1591
|
+
var N;
|
|
1592
|
+
|
|
1593
|
+
if (isSequence) {
|
|
1594
|
+
var x = numeric(n[0]);
|
|
1595
|
+
var y = numeric(n[1]);
|
|
1596
|
+
var width = Math.max(n[0].length, n[1].length)
|
|
1597
|
+
var incr = n.length == 3
|
|
1598
|
+
? Math.abs(numeric(n[2]))
|
|
1599
|
+
: 1;
|
|
1600
|
+
var test = lte;
|
|
1601
|
+
var reverse = y < x;
|
|
1602
|
+
if (reverse) {
|
|
1603
|
+
incr *= -1;
|
|
1604
|
+
test = gte;
|
|
1605
|
+
}
|
|
1606
|
+
var pad = n.some(isPadded);
|
|
1607
|
+
|
|
1608
|
+
N = [];
|
|
1609
|
+
|
|
1610
|
+
for (var i = x; test(i, y); i += incr) {
|
|
1611
|
+
var c;
|
|
1612
|
+
if (isAlphaSequence) {
|
|
1613
|
+
c = String.fromCharCode(i);
|
|
1614
|
+
if (c === '\\')
|
|
1615
|
+
c = '';
|
|
1616
|
+
} else {
|
|
1617
|
+
c = String(i);
|
|
1618
|
+
if (pad) {
|
|
1619
|
+
var need = width - c.length;
|
|
1620
|
+
if (need > 0) {
|
|
1621
|
+
var z = new Array(need + 1).join('0');
|
|
1622
|
+
if (i < 0)
|
|
1623
|
+
c = '-' + z + c.slice(1);
|
|
1624
|
+
else
|
|
1625
|
+
c = z + c;
|
|
1626
|
+
}
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
N.push(c);
|
|
1630
|
+
}
|
|
1631
|
+
} else {
|
|
1632
|
+
N = [];
|
|
1633
|
+
|
|
1634
|
+
for (var j = 0; j < n.length; j++) {
|
|
1635
|
+
N.push.apply(N, expand(n[j], false));
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
|
|
1639
|
+
for (var j = 0; j < N.length; j++) {
|
|
1640
|
+
for (var k = 0; k < post.length; k++) {
|
|
1641
|
+
var expansion = pre + N[j] + post[k];
|
|
1642
|
+
if (!isTop || isSequence || expansion)
|
|
1643
|
+
expansions.push(expansion);
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
return expansions;
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
|
|
1652
|
+
|
|
1653
|
+
/***/ }),
|
|
1654
|
+
/* 8 */
|
|
1655
|
+
/***/ ((module) => {
|
|
1656
|
+
|
|
1657
|
+
"use strict";
|
|
1658
|
+
|
|
1659
|
+
module.exports = balanced;
|
|
1660
|
+
function balanced(a, b, str) {
|
|
1661
|
+
if (a instanceof RegExp) a = maybeMatch(a, str);
|
|
1662
|
+
if (b instanceof RegExp) b = maybeMatch(b, str);
|
|
1663
|
+
|
|
1664
|
+
var r = range(a, b, str);
|
|
1665
|
+
|
|
1666
|
+
return r && {
|
|
1667
|
+
start: r[0],
|
|
1668
|
+
end: r[1],
|
|
1669
|
+
pre: str.slice(0, r[0]),
|
|
1670
|
+
body: str.slice(r[0] + a.length, r[1]),
|
|
1671
|
+
post: str.slice(r[1] + b.length)
|
|
1672
|
+
};
|
|
1673
|
+
}
|
|
1674
|
+
|
|
1675
|
+
function maybeMatch(reg, str) {
|
|
1676
|
+
var m = str.match(reg);
|
|
1677
|
+
return m ? m[0] : null;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
balanced.range = range;
|
|
1681
|
+
function range(a, b, str) {
|
|
1682
|
+
var begs, beg, left, right, result;
|
|
1683
|
+
var ai = str.indexOf(a);
|
|
1684
|
+
var bi = str.indexOf(b, ai + 1);
|
|
1685
|
+
var i = ai;
|
|
1686
|
+
|
|
1687
|
+
if (ai >= 0 && bi > 0) {
|
|
1688
|
+
if(a===b) {
|
|
1689
|
+
return [ai, bi];
|
|
1690
|
+
}
|
|
1691
|
+
begs = [];
|
|
1692
|
+
left = str.length;
|
|
1693
|
+
|
|
1694
|
+
while (i >= 0 && !result) {
|
|
1695
|
+
if (i == ai) {
|
|
1696
|
+
begs.push(i);
|
|
1697
|
+
ai = str.indexOf(a, i + 1);
|
|
1698
|
+
} else if (begs.length == 1) {
|
|
1699
|
+
result = [ begs.pop(), bi ];
|
|
1700
|
+
} else {
|
|
1701
|
+
beg = begs.pop();
|
|
1702
|
+
if (beg < left) {
|
|
1703
|
+
left = beg;
|
|
1704
|
+
right = bi;
|
|
1705
|
+
}
|
|
1706
|
+
|
|
1707
|
+
bi = str.indexOf(b, i + 1);
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
1711
|
+
}
|
|
1712
|
+
|
|
1713
|
+
if (begs.length) {
|
|
1714
|
+
result = [ left, right ];
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
|
|
1718
|
+
return result;
|
|
1719
|
+
}
|
|
1720
|
+
|
|
1721
|
+
|
|
1722
|
+
/***/ }),
|
|
1723
|
+
/* 9 */
|
|
1724
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1725
|
+
|
|
1726
|
+
"use strict";
|
|
1727
|
+
|
|
1728
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1729
|
+
exports.assertValidPattern = void 0;
|
|
1730
|
+
const MAX_PATTERN_LENGTH = 1024 * 64;
|
|
1731
|
+
const assertValidPattern = (pattern) => {
|
|
1732
|
+
if (typeof pattern !== 'string') {
|
|
1733
|
+
throw new TypeError('invalid pattern');
|
|
1734
|
+
}
|
|
1735
|
+
if (pattern.length > MAX_PATTERN_LENGTH) {
|
|
1736
|
+
throw new TypeError('pattern is too long');
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
exports.assertValidPattern = assertValidPattern;
|
|
1740
|
+
//# sourceMappingURL=assert-valid-pattern.js.map
|
|
1741
|
+
|
|
1742
|
+
/***/ }),
|
|
1743
|
+
/* 10 */
|
|
1744
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1745
|
+
|
|
1746
|
+
"use strict";
|
|
1747
|
+
|
|
1748
|
+
// parse a single path portion
|
|
1749
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1750
|
+
exports.AST = void 0;
|
|
1751
|
+
const brace_expressions_js_1 = __webpack_require__(11);
|
|
1752
|
+
const unescape_js_1 = __webpack_require__(12);
|
|
1753
|
+
const types = new Set(['!', '?', '+', '*', '@']);
|
|
1754
|
+
const isExtglobType = (c) => types.has(c);
|
|
1755
|
+
// Patterns that get prepended to bind to the start of either the
|
|
1756
|
+
// entire string, or just a single path portion, to prevent dots
|
|
1757
|
+
// and/or traversal patterns, when needed.
|
|
1758
|
+
// Exts don't need the ^ or / bit, because the root binds that already.
|
|
1759
|
+
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
1760
|
+
const startNoDot = '(?!\\.)';
|
|
1761
|
+
// characters that indicate a start of pattern needs the "no dots" bit,
|
|
1762
|
+
// because a dot *might* be matched. ( is not in the list, because in
|
|
1763
|
+
// the case of a child extglob, it will handle the prevention itself.
|
|
1764
|
+
const addPatternStart = new Set(['[', '.']);
|
|
1765
|
+
// cases where traversal is A-OK, no dot prevention needed
|
|
1766
|
+
const justDots = new Set(['..', '.']);
|
|
1767
|
+
const reSpecials = new Set('().*{}+?[]^$\\!');
|
|
1768
|
+
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
1769
|
+
// any single thing other than /
|
|
1770
|
+
const qmark = '[^/]';
|
|
1771
|
+
// * => any number of characters
|
|
1772
|
+
const star = qmark + '*?';
|
|
1773
|
+
// use + when we need to ensure that *something* matches, because the * is
|
|
1774
|
+
// the only thing in the path portion.
|
|
1775
|
+
const starNoEmpty = qmark + '+?';
|
|
1776
|
+
// remove the \ chars that we added if we end up doing a nonmagic compare
|
|
1777
|
+
// const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
|
|
1778
|
+
class AST {
|
|
1779
|
+
type;
|
|
1780
|
+
#root;
|
|
1781
|
+
#hasMagic;
|
|
1782
|
+
#uflag = false;
|
|
1783
|
+
#parts = [];
|
|
1784
|
+
#parent;
|
|
1785
|
+
#parentIndex;
|
|
1786
|
+
#negs;
|
|
1787
|
+
#filledNegs = false;
|
|
1788
|
+
#options;
|
|
1789
|
+
#toString;
|
|
1790
|
+
// set to true if it's an extglob with no children
|
|
1791
|
+
// (which really means one child of '')
|
|
1792
|
+
#emptyExt = false;
|
|
1793
|
+
constructor(type, parent, options = {}) {
|
|
1794
|
+
this.type = type;
|
|
1795
|
+
// extglobs are inherently magical
|
|
1796
|
+
if (type)
|
|
1797
|
+
this.#hasMagic = true;
|
|
1798
|
+
this.#parent = parent;
|
|
1799
|
+
this.#root = this.#parent ? this.#parent.#root : this;
|
|
1800
|
+
this.#options = this.#root === this ? options : this.#root.#options;
|
|
1801
|
+
this.#negs = this.#root === this ? [] : this.#root.#negs;
|
|
1802
|
+
if (type === '!' && !this.#root.#filledNegs)
|
|
1803
|
+
this.#negs.push(this);
|
|
1804
|
+
this.#parentIndex = this.#parent ? this.#parent.#parts.length : 0;
|
|
1805
|
+
}
|
|
1806
|
+
get hasMagic() {
|
|
1807
|
+
/* c8 ignore start */
|
|
1808
|
+
if (this.#hasMagic !== undefined)
|
|
1809
|
+
return this.#hasMagic;
|
|
1810
|
+
/* c8 ignore stop */
|
|
1811
|
+
for (const p of this.#parts) {
|
|
1812
|
+
if (typeof p === 'string')
|
|
1813
|
+
continue;
|
|
1814
|
+
if (p.type || p.hasMagic)
|
|
1815
|
+
return (this.#hasMagic = true);
|
|
1816
|
+
}
|
|
1817
|
+
// note: will be undefined until we generate the regexp src and find out
|
|
1818
|
+
return this.#hasMagic;
|
|
1819
|
+
}
|
|
1820
|
+
// reconstructs the pattern
|
|
1821
|
+
toString() {
|
|
1822
|
+
if (this.#toString !== undefined)
|
|
1823
|
+
return this.#toString;
|
|
1824
|
+
if (!this.type) {
|
|
1825
|
+
return (this.#toString = this.#parts.map(p => String(p)).join(''));
|
|
1826
|
+
}
|
|
1827
|
+
else {
|
|
1828
|
+
return (this.#toString =
|
|
1829
|
+
this.type + '(' + this.#parts.map(p => String(p)).join('|') + ')');
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
#fillNegs() {
|
|
1833
|
+
/* c8 ignore start */
|
|
1834
|
+
if (this !== this.#root)
|
|
1835
|
+
throw new Error('should only call on root');
|
|
1836
|
+
if (this.#filledNegs)
|
|
1837
|
+
return this;
|
|
1838
|
+
/* c8 ignore stop */
|
|
1839
|
+
// call toString() once to fill this out
|
|
1840
|
+
this.toString();
|
|
1841
|
+
this.#filledNegs = true;
|
|
1842
|
+
let n;
|
|
1843
|
+
while ((n = this.#negs.pop())) {
|
|
1844
|
+
if (n.type !== '!')
|
|
1845
|
+
continue;
|
|
1846
|
+
// walk up the tree, appending everthing that comes AFTER parentIndex
|
|
1847
|
+
let p = n;
|
|
1848
|
+
let pp = p.#parent;
|
|
1849
|
+
while (pp) {
|
|
1850
|
+
for (let i = p.#parentIndex + 1; !pp.type && i < pp.#parts.length; i++) {
|
|
1851
|
+
for (const part of n.#parts) {
|
|
1852
|
+
/* c8 ignore start */
|
|
1853
|
+
if (typeof part === 'string') {
|
|
1854
|
+
throw new Error('string part in extglob AST??');
|
|
1855
|
+
}
|
|
1856
|
+
/* c8 ignore stop */
|
|
1857
|
+
part.copyIn(pp.#parts[i]);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
p = pp;
|
|
1861
|
+
pp = p.#parent;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
return this;
|
|
1865
|
+
}
|
|
1866
|
+
push(...parts) {
|
|
1867
|
+
for (const p of parts) {
|
|
1868
|
+
if (p === '')
|
|
1869
|
+
continue;
|
|
1870
|
+
/* c8 ignore start */
|
|
1871
|
+
if (typeof p !== 'string' && !(p instanceof AST && p.#parent === this)) {
|
|
1872
|
+
throw new Error('invalid part: ' + p);
|
|
1873
|
+
}
|
|
1874
|
+
/* c8 ignore stop */
|
|
1875
|
+
this.#parts.push(p);
|
|
1876
|
+
}
|
|
1877
|
+
}
|
|
1878
|
+
toJSON() {
|
|
1879
|
+
const ret = this.type === null
|
|
1880
|
+
? this.#parts.slice().map(p => (typeof p === 'string' ? p : p.toJSON()))
|
|
1881
|
+
: [this.type, ...this.#parts.map(p => p.toJSON())];
|
|
1882
|
+
if (this.isStart() && !this.type)
|
|
1883
|
+
ret.unshift([]);
|
|
1884
|
+
if (this.isEnd() &&
|
|
1885
|
+
(this === this.#root ||
|
|
1886
|
+
(this.#root.#filledNegs && this.#parent?.type === '!'))) {
|
|
1887
|
+
ret.push({});
|
|
1888
|
+
}
|
|
1889
|
+
return ret;
|
|
1890
|
+
}
|
|
1891
|
+
isStart() {
|
|
1892
|
+
if (this.#root === this)
|
|
1893
|
+
return true;
|
|
1894
|
+
// if (this.type) return !!this.#parent?.isStart()
|
|
1895
|
+
if (!this.#parent?.isStart())
|
|
1896
|
+
return false;
|
|
1897
|
+
if (this.#parentIndex === 0)
|
|
1898
|
+
return true;
|
|
1899
|
+
// if everything AHEAD of this is a negation, then it's still the "start"
|
|
1900
|
+
const p = this.#parent;
|
|
1901
|
+
for (let i = 0; i < this.#parentIndex; i++) {
|
|
1902
|
+
const pp = p.#parts[i];
|
|
1903
|
+
if (!(pp instanceof AST && pp.type === '!')) {
|
|
1904
|
+
return false;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
return true;
|
|
1908
|
+
}
|
|
1909
|
+
isEnd() {
|
|
1910
|
+
if (this.#root === this)
|
|
1911
|
+
return true;
|
|
1912
|
+
if (this.#parent?.type === '!')
|
|
1913
|
+
return true;
|
|
1914
|
+
if (!this.#parent?.isEnd())
|
|
1915
|
+
return false;
|
|
1916
|
+
if (!this.type)
|
|
1917
|
+
return this.#parent?.isEnd();
|
|
1918
|
+
// if not root, it'll always have a parent
|
|
1919
|
+
/* c8 ignore start */
|
|
1920
|
+
const pl = this.#parent ? this.#parent.#parts.length : 0;
|
|
1921
|
+
/* c8 ignore stop */
|
|
1922
|
+
return this.#parentIndex === pl - 1;
|
|
1923
|
+
}
|
|
1924
|
+
copyIn(part) {
|
|
1925
|
+
if (typeof part === 'string')
|
|
1926
|
+
this.push(part);
|
|
1927
|
+
else
|
|
1928
|
+
this.push(part.clone(this));
|
|
1929
|
+
}
|
|
1930
|
+
clone(parent) {
|
|
1931
|
+
const c = new AST(this.type, parent);
|
|
1932
|
+
for (const p of this.#parts) {
|
|
1933
|
+
c.copyIn(p);
|
|
1934
|
+
}
|
|
1935
|
+
return c;
|
|
1936
|
+
}
|
|
1937
|
+
static #parseAST(str, ast, pos, opt) {
|
|
1938
|
+
let escaping = false;
|
|
1939
|
+
let inBrace = false;
|
|
1940
|
+
let braceStart = -1;
|
|
1941
|
+
let braceNeg = false;
|
|
1942
|
+
if (ast.type === null) {
|
|
1943
|
+
// outside of a extglob, append until we find a start
|
|
1944
|
+
let i = pos;
|
|
1945
|
+
let acc = '';
|
|
1946
|
+
while (i < str.length) {
|
|
1947
|
+
const c = str.charAt(i++);
|
|
1948
|
+
// still accumulate escapes at this point, but we do ignore
|
|
1949
|
+
// starts that are escaped
|
|
1950
|
+
if (escaping || c === '\\') {
|
|
1951
|
+
escaping = !escaping;
|
|
1952
|
+
acc += c;
|
|
1953
|
+
continue;
|
|
1954
|
+
}
|
|
1955
|
+
if (inBrace) {
|
|
1956
|
+
if (i === braceStart + 1) {
|
|
1957
|
+
if (c === '^' || c === '!') {
|
|
1958
|
+
braceNeg = true;
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
|
|
1962
|
+
inBrace = false;
|
|
1963
|
+
}
|
|
1964
|
+
acc += c;
|
|
1965
|
+
continue;
|
|
1966
|
+
}
|
|
1967
|
+
else if (c === '[') {
|
|
1968
|
+
inBrace = true;
|
|
1969
|
+
braceStart = i;
|
|
1970
|
+
braceNeg = false;
|
|
1971
|
+
acc += c;
|
|
1972
|
+
continue;
|
|
1973
|
+
}
|
|
1974
|
+
if (!opt.noext && isExtglobType(c) && str.charAt(i) === '(') {
|
|
1975
|
+
ast.push(acc);
|
|
1976
|
+
acc = '';
|
|
1977
|
+
const ext = new AST(c, ast);
|
|
1978
|
+
i = AST.#parseAST(str, ext, i, opt);
|
|
1979
|
+
ast.push(ext);
|
|
1980
|
+
continue;
|
|
1981
|
+
}
|
|
1982
|
+
acc += c;
|
|
1983
|
+
}
|
|
1984
|
+
ast.push(acc);
|
|
1985
|
+
return i;
|
|
1986
|
+
}
|
|
1987
|
+
// some kind of extglob, pos is at the (
|
|
1988
|
+
// find the next | or )
|
|
1989
|
+
let i = pos + 1;
|
|
1990
|
+
let part = new AST(null, ast);
|
|
1991
|
+
const parts = [];
|
|
1992
|
+
let acc = '';
|
|
1993
|
+
while (i < str.length) {
|
|
1994
|
+
const c = str.charAt(i++);
|
|
1995
|
+
// still accumulate escapes at this point, but we do ignore
|
|
1996
|
+
// starts that are escaped
|
|
1997
|
+
if (escaping || c === '\\') {
|
|
1998
|
+
escaping = !escaping;
|
|
1999
|
+
acc += c;
|
|
2000
|
+
continue;
|
|
2001
|
+
}
|
|
2002
|
+
if (inBrace) {
|
|
2003
|
+
if (i === braceStart + 1) {
|
|
2004
|
+
if (c === '^' || c === '!') {
|
|
2005
|
+
braceNeg = true;
|
|
2006
|
+
}
|
|
2007
|
+
}
|
|
2008
|
+
else if (c === ']' && !(i === braceStart + 2 && braceNeg)) {
|
|
2009
|
+
inBrace = false;
|
|
2010
|
+
}
|
|
2011
|
+
acc += c;
|
|
2012
|
+
continue;
|
|
2013
|
+
}
|
|
2014
|
+
else if (c === '[') {
|
|
2015
|
+
inBrace = true;
|
|
2016
|
+
braceStart = i;
|
|
2017
|
+
braceNeg = false;
|
|
2018
|
+
acc += c;
|
|
2019
|
+
continue;
|
|
2020
|
+
}
|
|
2021
|
+
if (isExtglobType(c) && str.charAt(i) === '(') {
|
|
2022
|
+
part.push(acc);
|
|
2023
|
+
acc = '';
|
|
2024
|
+
const ext = new AST(c, part);
|
|
2025
|
+
part.push(ext);
|
|
2026
|
+
i = AST.#parseAST(str, ext, i, opt);
|
|
2027
|
+
continue;
|
|
2028
|
+
}
|
|
2029
|
+
if (c === '|') {
|
|
2030
|
+
part.push(acc);
|
|
2031
|
+
acc = '';
|
|
2032
|
+
parts.push(part);
|
|
2033
|
+
part = new AST(null, ast);
|
|
2034
|
+
continue;
|
|
2035
|
+
}
|
|
2036
|
+
if (c === ')') {
|
|
2037
|
+
if (acc === '' && ast.#parts.length === 0) {
|
|
2038
|
+
ast.#emptyExt = true;
|
|
2039
|
+
}
|
|
2040
|
+
part.push(acc);
|
|
2041
|
+
acc = '';
|
|
2042
|
+
ast.push(...parts, part);
|
|
2043
|
+
return i;
|
|
2044
|
+
}
|
|
2045
|
+
acc += c;
|
|
2046
|
+
}
|
|
2047
|
+
// unfinished extglob
|
|
2048
|
+
// if we got here, it was a malformed extglob! not an extglob, but
|
|
2049
|
+
// maybe something else in there.
|
|
2050
|
+
ast.type = null;
|
|
2051
|
+
ast.#hasMagic = undefined;
|
|
2052
|
+
ast.#parts = [str.substring(pos - 1)];
|
|
2053
|
+
return i;
|
|
2054
|
+
}
|
|
2055
|
+
static fromGlob(pattern, options = {}) {
|
|
2056
|
+
const ast = new AST(null, undefined, options);
|
|
2057
|
+
AST.#parseAST(pattern, ast, 0, options);
|
|
2058
|
+
return ast;
|
|
2059
|
+
}
|
|
2060
|
+
// returns the regular expression if there's magic, or the unescaped
|
|
2061
|
+
// string if not.
|
|
2062
|
+
toMMPattern() {
|
|
2063
|
+
// should only be called on root
|
|
2064
|
+
/* c8 ignore start */
|
|
2065
|
+
if (this !== this.#root)
|
|
2066
|
+
return this.#root.toMMPattern();
|
|
2067
|
+
/* c8 ignore stop */
|
|
2068
|
+
const glob = this.toString();
|
|
2069
|
+
const [re, body, hasMagic, uflag] = this.toRegExpSource();
|
|
2070
|
+
// if we're in nocase mode, and not nocaseMagicOnly, then we do
|
|
2071
|
+
// still need a regular expression if we have to case-insensitively
|
|
2072
|
+
// match capital/lowercase characters.
|
|
2073
|
+
const anyMagic = hasMagic ||
|
|
2074
|
+
this.#hasMagic ||
|
|
2075
|
+
(this.#options.nocase &&
|
|
2076
|
+
!this.#options.nocaseMagicOnly &&
|
|
2077
|
+
glob.toUpperCase() !== glob.toLowerCase());
|
|
2078
|
+
if (!anyMagic) {
|
|
2079
|
+
return body;
|
|
2080
|
+
}
|
|
2081
|
+
const flags = (this.#options.nocase ? 'i' : '') + (uflag ? 'u' : '');
|
|
2082
|
+
return Object.assign(new RegExp(`^${re}$`, flags), {
|
|
2083
|
+
_src: re,
|
|
2084
|
+
_glob: glob,
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
// returns the string match, the regexp source, whether there's magic
|
|
2088
|
+
// in the regexp (so a regular expression is required) and whether or
|
|
2089
|
+
// not the uflag is needed for the regular expression (for posix classes)
|
|
2090
|
+
// TODO: instead of injecting the start/end at this point, just return
|
|
2091
|
+
// the BODY of the regexp, along with the start/end portions suitable
|
|
2092
|
+
// for binding the start/end in either a joined full-path makeRe context
|
|
2093
|
+
// (where we bind to (^|/), or a standalone matchPart context (where
|
|
2094
|
+
// we bind to ^, and not /). Otherwise slashes get duped!
|
|
2095
|
+
//
|
|
2096
|
+
// In part-matching mode, the start is:
|
|
2097
|
+
// - if not isStart: nothing
|
|
2098
|
+
// - if traversal possible, but not allowed: ^(?!\.\.?$)
|
|
2099
|
+
// - if dots allowed or not possible: ^
|
|
2100
|
+
// - if dots possible and not allowed: ^(?!\.)
|
|
2101
|
+
// end is:
|
|
2102
|
+
// - if not isEnd(): nothing
|
|
2103
|
+
// - else: $
|
|
2104
|
+
//
|
|
2105
|
+
// In full-path matching mode, we put the slash at the START of the
|
|
2106
|
+
// pattern, so start is:
|
|
2107
|
+
// - if first pattern: same as part-matching mode
|
|
2108
|
+
// - if not isStart(): nothing
|
|
2109
|
+
// - if traversal possible, but not allowed: /(?!\.\.?(?:$|/))
|
|
2110
|
+
// - if dots allowed or not possible: /
|
|
2111
|
+
// - if dots possible and not allowed: /(?!\.)
|
|
2112
|
+
// end is:
|
|
2113
|
+
// - if last pattern, same as part-matching mode
|
|
2114
|
+
// - else nothing
|
|
2115
|
+
//
|
|
2116
|
+
// Always put the (?:$|/) on negated tails, though, because that has to be
|
|
2117
|
+
// there to bind the end of the negated pattern portion, and it's easier to
|
|
2118
|
+
// just stick it in now rather than try to inject it later in the middle of
|
|
2119
|
+
// the pattern.
|
|
2120
|
+
//
|
|
2121
|
+
// We can just always return the same end, and leave it up to the caller
|
|
2122
|
+
// to know whether it's going to be used joined or in parts.
|
|
2123
|
+
// And, if the start is adjusted slightly, can do the same there:
|
|
2124
|
+
// - if not isStart: nothing
|
|
2125
|
+
// - if traversal possible, but not allowed: (?:/|^)(?!\.\.?$)
|
|
2126
|
+
// - if dots allowed or not possible: (?:/|^)
|
|
2127
|
+
// - if dots possible and not allowed: (?:/|^)(?!\.)
|
|
2128
|
+
//
|
|
2129
|
+
// But it's better to have a simpler binding without a conditional, for
|
|
2130
|
+
// performance, so probably better to return both start options.
|
|
2131
|
+
//
|
|
2132
|
+
// Then the caller just ignores the end if it's not the first pattern,
|
|
2133
|
+
// and the start always gets applied.
|
|
2134
|
+
//
|
|
2135
|
+
// But that's always going to be $ if it's the ending pattern, or nothing,
|
|
2136
|
+
// so the caller can just attach $ at the end of the pattern when building.
|
|
2137
|
+
//
|
|
2138
|
+
// So the todo is:
|
|
2139
|
+
// - better detect what kind of start is needed
|
|
2140
|
+
// - return both flavors of starting pattern
|
|
2141
|
+
// - attach $ at the end of the pattern when creating the actual RegExp
|
|
2142
|
+
//
|
|
2143
|
+
// Ah, but wait, no, that all only applies to the root when the first pattern
|
|
2144
|
+
// is not an extglob. If the first pattern IS an extglob, then we need all
|
|
2145
|
+
// that dot prevention biz to live in the extglob portions, because eg
|
|
2146
|
+
// +(*|.x*) can match .xy but not .yx.
|
|
2147
|
+
//
|
|
2148
|
+
// So, return the two flavors if it's #root and the first child is not an
|
|
2149
|
+
// AST, otherwise leave it to the child AST to handle it, and there,
|
|
2150
|
+
// use the (?:^|/) style of start binding.
|
|
2151
|
+
//
|
|
2152
|
+
// Even simplified further:
|
|
2153
|
+
// - Since the start for a join is eg /(?!\.) and the start for a part
|
|
2154
|
+
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
|
|
2155
|
+
// or start or whatever) and prepend ^ or / at the Regexp construction.
|
|
2156
|
+
toRegExpSource(allowDot) {
|
|
2157
|
+
const dot = allowDot ?? !!this.#options.dot;
|
|
2158
|
+
if (this.#root === this)
|
|
2159
|
+
this.#fillNegs();
|
|
2160
|
+
if (!this.type) {
|
|
2161
|
+
const noEmpty = this.isStart() && this.isEnd();
|
|
2162
|
+
const src = this.#parts
|
|
2163
|
+
.map(p => {
|
|
2164
|
+
const [re, _, hasMagic, uflag] = typeof p === 'string'
|
|
2165
|
+
? AST.#parseGlob(p, this.#hasMagic, noEmpty)
|
|
2166
|
+
: p.toRegExpSource(allowDot);
|
|
2167
|
+
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
2168
|
+
this.#uflag = this.#uflag || uflag;
|
|
2169
|
+
return re;
|
|
2170
|
+
})
|
|
2171
|
+
.join('');
|
|
2172
|
+
let start = '';
|
|
2173
|
+
if (this.isStart()) {
|
|
2174
|
+
if (typeof this.#parts[0] === 'string') {
|
|
2175
|
+
// this is the string that will match the start of the pattern,
|
|
2176
|
+
// so we need to protect against dots and such.
|
|
2177
|
+
// '.' and '..' cannot match unless the pattern is that exactly,
|
|
2178
|
+
// even if it starts with . or dot:true is set.
|
|
2179
|
+
const dotTravAllowed = this.#parts.length === 1 && justDots.has(this.#parts[0]);
|
|
2180
|
+
if (!dotTravAllowed) {
|
|
2181
|
+
const aps = addPatternStart;
|
|
2182
|
+
// check if we have a possibility of matching . or ..,
|
|
2183
|
+
// and prevent that.
|
|
2184
|
+
const needNoTrav =
|
|
2185
|
+
// dots are allowed, and the pattern starts with [ or .
|
|
2186
|
+
(dot && aps.has(src.charAt(0))) ||
|
|
2187
|
+
// the pattern starts with \., and then [ or .
|
|
2188
|
+
(src.startsWith('\\.') && aps.has(src.charAt(2))) ||
|
|
2189
|
+
// the pattern starts with \.\., and then [ or .
|
|
2190
|
+
(src.startsWith('\\.\\.') && aps.has(src.charAt(4)));
|
|
2191
|
+
// no need to prevent dots if it can't match a dot, or if a
|
|
2192
|
+
// sub-pattern will be preventing it anyway.
|
|
2193
|
+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
|
|
2194
|
+
start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
}
|
|
2198
|
+
// append the "end of path portion" pattern to negation tails
|
|
2199
|
+
let end = '';
|
|
2200
|
+
if (this.isEnd() &&
|
|
2201
|
+
this.#root.#filledNegs &&
|
|
2202
|
+
this.#parent?.type === '!') {
|
|
2203
|
+
end = '(?:$|\\/)';
|
|
2204
|
+
}
|
|
2205
|
+
const final = start + src + end;
|
|
2206
|
+
return [
|
|
2207
|
+
final,
|
|
2208
|
+
(0, unescape_js_1.unescape)(src),
|
|
2209
|
+
(this.#hasMagic = !!this.#hasMagic),
|
|
2210
|
+
this.#uflag,
|
|
2211
|
+
];
|
|
2212
|
+
}
|
|
2213
|
+
// We need to calculate the body *twice* if it's a repeat pattern
|
|
2214
|
+
// at the start, once in nodot mode, then again in dot mode, so a
|
|
2215
|
+
// pattern like *(?) can match 'x.y'
|
|
2216
|
+
const repeated = this.type === '*' || this.type === '+';
|
|
2217
|
+
// some kind of extglob
|
|
2218
|
+
const start = this.type === '!' ? '(?:(?!(?:' : '(?:';
|
|
2219
|
+
let body = this.#partsToRegExp(dot);
|
|
2220
|
+
if (this.isStart() && this.isEnd() && !body && this.type !== '!') {
|
|
2221
|
+
// invalid extglob, has to at least be *something* present, if it's
|
|
2222
|
+
// the entire path portion.
|
|
2223
|
+
const s = this.toString();
|
|
2224
|
+
this.#parts = [s];
|
|
2225
|
+
this.type = null;
|
|
2226
|
+
this.#hasMagic = undefined;
|
|
2227
|
+
return [s, (0, unescape_js_1.unescape)(this.toString()), false, false];
|
|
2228
|
+
}
|
|
2229
|
+
// XXX abstract out this map method
|
|
2230
|
+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot
|
|
2231
|
+
? ''
|
|
2232
|
+
: this.#partsToRegExp(true);
|
|
2233
|
+
if (bodyDotAllowed === body) {
|
|
2234
|
+
bodyDotAllowed = '';
|
|
2235
|
+
}
|
|
2236
|
+
if (bodyDotAllowed) {
|
|
2237
|
+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
|
|
2238
|
+
}
|
|
2239
|
+
// an empty !() is exactly equivalent to a starNoEmpty
|
|
2240
|
+
let final = '';
|
|
2241
|
+
if (this.type === '!' && this.#emptyExt) {
|
|
2242
|
+
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
|
|
2243
|
+
}
|
|
2244
|
+
else {
|
|
2245
|
+
const close = this.type === '!'
|
|
2246
|
+
? // !() must match something,but !(x) can match ''
|
|
2247
|
+
'))' +
|
|
2248
|
+
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
|
|
2249
|
+
star +
|
|
2250
|
+
')'
|
|
2251
|
+
: this.type === '@'
|
|
2252
|
+
? ')'
|
|
2253
|
+
: this.type === '?'
|
|
2254
|
+
? ')?'
|
|
2255
|
+
: this.type === '+' && bodyDotAllowed
|
|
2256
|
+
? ')'
|
|
2257
|
+
: this.type === '*' && bodyDotAllowed
|
|
2258
|
+
? `)?`
|
|
2259
|
+
: `)${this.type}`;
|
|
2260
|
+
final = start + body + close;
|
|
2261
|
+
}
|
|
2262
|
+
return [
|
|
2263
|
+
final,
|
|
2264
|
+
(0, unescape_js_1.unescape)(body),
|
|
2265
|
+
(this.#hasMagic = !!this.#hasMagic),
|
|
2266
|
+
this.#uflag,
|
|
2267
|
+
];
|
|
2268
|
+
}
|
|
2269
|
+
#partsToRegExp(dot) {
|
|
2270
|
+
return this.#parts
|
|
2271
|
+
.map(p => {
|
|
2272
|
+
// extglob ASTs should only contain parent ASTs
|
|
2273
|
+
/* c8 ignore start */
|
|
2274
|
+
if (typeof p === 'string') {
|
|
2275
|
+
throw new Error('string type in extglob ast??');
|
|
2276
|
+
}
|
|
2277
|
+
/* c8 ignore stop */
|
|
2278
|
+
// can ignore hasMagic, because extglobs are already always magic
|
|
2279
|
+
const [re, _, _hasMagic, uflag] = p.toRegExpSource(dot);
|
|
2280
|
+
this.#uflag = this.#uflag || uflag;
|
|
2281
|
+
return re;
|
|
2282
|
+
})
|
|
2283
|
+
.filter(p => !(this.isStart() && this.isEnd()) || !!p)
|
|
2284
|
+
.join('|');
|
|
2285
|
+
}
|
|
2286
|
+
static #parseGlob(glob, hasMagic, noEmpty = false) {
|
|
2287
|
+
let escaping = false;
|
|
2288
|
+
let re = '';
|
|
2289
|
+
let uflag = false;
|
|
2290
|
+
for (let i = 0; i < glob.length; i++) {
|
|
2291
|
+
const c = glob.charAt(i);
|
|
2292
|
+
if (escaping) {
|
|
2293
|
+
escaping = false;
|
|
2294
|
+
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
2295
|
+
continue;
|
|
2296
|
+
}
|
|
2297
|
+
if (c === '\\') {
|
|
2298
|
+
if (i === glob.length - 1) {
|
|
2299
|
+
re += '\\\\';
|
|
2300
|
+
}
|
|
2301
|
+
else {
|
|
2302
|
+
escaping = true;
|
|
2303
|
+
}
|
|
2304
|
+
continue;
|
|
2305
|
+
}
|
|
2306
|
+
if (c === '[') {
|
|
2307
|
+
const [src, needUflag, consumed, magic] = (0, brace_expressions_js_1.parseClass)(glob, i);
|
|
2308
|
+
if (consumed) {
|
|
2309
|
+
re += src;
|
|
2310
|
+
uflag = uflag || needUflag;
|
|
2311
|
+
i += consumed - 1;
|
|
2312
|
+
hasMagic = hasMagic || magic;
|
|
2313
|
+
continue;
|
|
2314
|
+
}
|
|
2315
|
+
}
|
|
2316
|
+
if (c === '*') {
|
|
2317
|
+
if (noEmpty && glob === '*')
|
|
2318
|
+
re += starNoEmpty;
|
|
2319
|
+
else
|
|
2320
|
+
re += star;
|
|
2321
|
+
hasMagic = true;
|
|
2322
|
+
continue;
|
|
2323
|
+
}
|
|
2324
|
+
if (c === '?') {
|
|
2325
|
+
re += qmark;
|
|
2326
|
+
hasMagic = true;
|
|
2327
|
+
continue;
|
|
2328
|
+
}
|
|
2329
|
+
re += regExpEscape(c);
|
|
2330
|
+
}
|
|
2331
|
+
return [re, (0, unescape_js_1.unescape)(glob), !!hasMagic, uflag];
|
|
2332
|
+
}
|
|
2333
|
+
}
|
|
2334
|
+
exports.AST = AST;
|
|
2335
|
+
//# sourceMappingURL=ast.js.map
|
|
2336
|
+
|
|
2337
|
+
/***/ }),
|
|
2338
|
+
/* 11 */
|
|
2339
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2340
|
+
|
|
2341
|
+
"use strict";
|
|
2342
|
+
|
|
2343
|
+
// translate the various posix character classes into unicode properties
|
|
2344
|
+
// this works across all unicode locales
|
|
2345
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2346
|
+
exports.parseClass = void 0;
|
|
2347
|
+
// { <posix class>: [<translation>, /u flag required, negated]
|
|
2348
|
+
const posixClasses = {
|
|
2349
|
+
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}', true],
|
|
2350
|
+
'[:alpha:]': ['\\p{L}\\p{Nl}', true],
|
|
2351
|
+
'[:ascii:]': ['\\x' + '00-\\x' + '7f', false],
|
|
2352
|
+
'[:blank:]': ['\\p{Zs}\\t', true],
|
|
2353
|
+
'[:cntrl:]': ['\\p{Cc}', true],
|
|
2354
|
+
'[:digit:]': ['\\p{Nd}', true],
|
|
2355
|
+
'[:graph:]': ['\\p{Z}\\p{C}', true, true],
|
|
2356
|
+
'[:lower:]': ['\\p{Ll}', true],
|
|
2357
|
+
'[:print:]': ['\\p{C}', true],
|
|
2358
|
+
'[:punct:]': ['\\p{P}', true],
|
|
2359
|
+
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f', true],
|
|
2360
|
+
'[:upper:]': ['\\p{Lu}', true],
|
|
2361
|
+
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}', true],
|
|
2362
|
+
'[:xdigit:]': ['A-Fa-f0-9', false],
|
|
2363
|
+
};
|
|
2364
|
+
// only need to escape a few things inside of brace expressions
|
|
2365
|
+
// escapes: [ \ ] -
|
|
2366
|
+
const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
|
|
2367
|
+
// escape all regexp magic characters
|
|
2368
|
+
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
2369
|
+
// everything has already been escaped, we just have to join
|
|
2370
|
+
const rangesToString = (ranges) => ranges.join('');
|
|
2371
|
+
// takes a glob string at a posix brace expression, and returns
|
|
2372
|
+
// an equivalent regular expression source, and boolean indicating
|
|
2373
|
+
// whether the /u flag needs to be applied, and the number of chars
|
|
2374
|
+
// consumed to parse the character class.
|
|
2375
|
+
// This also removes out of order ranges, and returns ($.) if the
|
|
2376
|
+
// entire class just no good.
|
|
2377
|
+
const parseClass = (glob, position) => {
|
|
2378
|
+
const pos = position;
|
|
2379
|
+
/* c8 ignore start */
|
|
2380
|
+
if (glob.charAt(pos) !== '[') {
|
|
2381
|
+
throw new Error('not in a brace expression');
|
|
2382
|
+
}
|
|
2383
|
+
/* c8 ignore stop */
|
|
2384
|
+
const ranges = [];
|
|
2385
|
+
const negs = [];
|
|
2386
|
+
let i = pos + 1;
|
|
2387
|
+
let sawStart = false;
|
|
2388
|
+
let uflag = false;
|
|
2389
|
+
let escaping = false;
|
|
2390
|
+
let negate = false;
|
|
2391
|
+
let endPos = pos;
|
|
2392
|
+
let rangeStart = '';
|
|
2393
|
+
WHILE: while (i < glob.length) {
|
|
2394
|
+
const c = glob.charAt(i);
|
|
2395
|
+
if ((c === '!' || c === '^') && i === pos + 1) {
|
|
2396
|
+
negate = true;
|
|
2397
|
+
i++;
|
|
2398
|
+
continue;
|
|
2399
|
+
}
|
|
2400
|
+
if (c === ']' && sawStart && !escaping) {
|
|
2401
|
+
endPos = i + 1;
|
|
2402
|
+
break;
|
|
2403
|
+
}
|
|
2404
|
+
sawStart = true;
|
|
2405
|
+
if (c === '\\') {
|
|
2406
|
+
if (!escaping) {
|
|
2407
|
+
escaping = true;
|
|
2408
|
+
i++;
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
// escaped \ char, fall through and treat like normal char
|
|
2412
|
+
}
|
|
2413
|
+
if (c === '[' && !escaping) {
|
|
2414
|
+
// either a posix class, a collation equivalent, or just a [
|
|
2415
|
+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
|
|
2416
|
+
if (glob.startsWith(cls, i)) {
|
|
2417
|
+
// invalid, [a-[] is fine, but not [a-[:alpha]]
|
|
2418
|
+
if (rangeStart) {
|
|
2419
|
+
return ['$.', false, glob.length - pos, true];
|
|
2420
|
+
}
|
|
2421
|
+
i += cls.length;
|
|
2422
|
+
if (neg)
|
|
2423
|
+
negs.push(unip);
|
|
2424
|
+
else
|
|
2425
|
+
ranges.push(unip);
|
|
2426
|
+
uflag = uflag || u;
|
|
2427
|
+
continue WHILE;
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
}
|
|
2431
|
+
// now it's just a normal character, effectively
|
|
2432
|
+
escaping = false;
|
|
2433
|
+
if (rangeStart) {
|
|
2434
|
+
// throw this range away if it's not valid, but others
|
|
2435
|
+
// can still match.
|
|
2436
|
+
if (c > rangeStart) {
|
|
2437
|
+
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(c));
|
|
2438
|
+
}
|
|
2439
|
+
else if (c === rangeStart) {
|
|
2440
|
+
ranges.push(braceEscape(c));
|
|
2441
|
+
}
|
|
2442
|
+
rangeStart = '';
|
|
2443
|
+
i++;
|
|
2444
|
+
continue;
|
|
2445
|
+
}
|
|
2446
|
+
// now might be the start of a range.
|
|
2447
|
+
// can be either c-d or c-] or c<more...>] or c] at this point
|
|
2448
|
+
if (glob.startsWith('-]', i + 1)) {
|
|
2449
|
+
ranges.push(braceEscape(c + '-'));
|
|
2450
|
+
i += 2;
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
if (glob.startsWith('-', i + 1)) {
|
|
2454
|
+
rangeStart = c;
|
|
2455
|
+
i += 2;
|
|
2456
|
+
continue;
|
|
2457
|
+
}
|
|
2458
|
+
// not the start of a range, just a single character
|
|
2459
|
+
ranges.push(braceEscape(c));
|
|
2460
|
+
i++;
|
|
2461
|
+
}
|
|
2462
|
+
if (endPos < i) {
|
|
2463
|
+
// didn't see the end of the class, not a valid class,
|
|
2464
|
+
// but might still be valid as a literal match.
|
|
2465
|
+
return ['', false, 0, false];
|
|
2466
|
+
}
|
|
2467
|
+
// if we got no ranges and no negates, then we have a range that
|
|
2468
|
+
// cannot possibly match anything, and that poisons the whole glob
|
|
2469
|
+
if (!ranges.length && !negs.length) {
|
|
2470
|
+
return ['$.', false, glob.length - pos, true];
|
|
2471
|
+
}
|
|
2472
|
+
// if we got one positive range, and it's a single character, then that's
|
|
2473
|
+
// not actually a magic pattern, it's just that one literal character.
|
|
2474
|
+
// we should not treat that as "magic", we should just return the literal
|
|
2475
|
+
// character. [_] is a perfectly valid way to escape glob magic chars.
|
|
2476
|
+
if (negs.length === 0 &&
|
|
2477
|
+
ranges.length === 1 &&
|
|
2478
|
+
/^\\?.$/.test(ranges[0]) &&
|
|
2479
|
+
!negate) {
|
|
2480
|
+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
|
|
2481
|
+
return [regexpEscape(r), false, endPos - pos, false];
|
|
2482
|
+
}
|
|
2483
|
+
const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
|
|
2484
|
+
const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
|
|
2485
|
+
const comb = ranges.length && negs.length
|
|
2486
|
+
? '(' + sranges + '|' + snegs + ')'
|
|
2487
|
+
: ranges.length
|
|
2488
|
+
? sranges
|
|
2489
|
+
: snegs;
|
|
2490
|
+
return [comb, uflag, endPos - pos, true];
|
|
2491
|
+
};
|
|
2492
|
+
exports.parseClass = parseClass;
|
|
2493
|
+
//# sourceMappingURL=brace-expressions.js.map
|
|
2494
|
+
|
|
2495
|
+
/***/ }),
|
|
2496
|
+
/* 12 */
|
|
2497
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2498
|
+
|
|
2499
|
+
"use strict";
|
|
2500
|
+
|
|
2501
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2502
|
+
exports.unescape = void 0;
|
|
2503
|
+
/**
|
|
2504
|
+
* Un-escape a string that has been escaped with {@link escape}.
|
|
2505
|
+
*
|
|
2506
|
+
* If the {@link windowsPathsNoEscape} option is used, then square-brace
|
|
2507
|
+
* escapes are removed, but not backslash escapes. For example, it will turn
|
|
2508
|
+
* the string `'[*]'` into `*`, but it will not turn `'\\*'` into `'*'`,
|
|
2509
|
+
* becuase `\` is a path separator in `windowsPathsNoEscape` mode.
|
|
2510
|
+
*
|
|
2511
|
+
* When `windowsPathsNoEscape` is not set, then both brace escapes and
|
|
2512
|
+
* backslash escapes are removed.
|
|
2513
|
+
*
|
|
2514
|
+
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
|
|
2515
|
+
* or unescaped.
|
|
2516
|
+
*/
|
|
2517
|
+
const unescape = (s, { windowsPathsNoEscape = false, } = {}) => {
|
|
2518
|
+
return windowsPathsNoEscape
|
|
2519
|
+
? s.replace(/\[([^\/\\])\]/g, '$1')
|
|
2520
|
+
: s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
|
|
2521
|
+
};
|
|
2522
|
+
exports.unescape = unescape;
|
|
2523
|
+
//# sourceMappingURL=unescape.js.map
|
|
2524
|
+
|
|
2525
|
+
/***/ }),
|
|
2526
|
+
/* 13 */
|
|
2527
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
2528
|
+
|
|
2529
|
+
"use strict";
|
|
2530
|
+
|
|
2531
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2532
|
+
exports.escape = void 0;
|
|
2533
|
+
/**
|
|
2534
|
+
* Escape all magic characters in a glob pattern.
|
|
2535
|
+
*
|
|
2536
|
+
* If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
|
|
2537
|
+
* option is used, then characters are escaped by wrapping in `[]`, because
|
|
2538
|
+
* a magic character wrapped in a character class can only be satisfied by
|
|
2539
|
+
* that exact character. In this mode, `\` is _not_ escaped, because it is
|
|
2540
|
+
* not interpreted as a magic character, but instead as a path separator.
|
|
2541
|
+
*/
|
|
2542
|
+
const escape = (s, { windowsPathsNoEscape = false, } = {}) => {
|
|
2543
|
+
// don't need to escape +@! because we escape the parens
|
|
2544
|
+
// that make those magic, and escaping ! as [!] isn't valid,
|
|
2545
|
+
// because [!]] is a valid glob class meaning not ']'.
|
|
2546
|
+
return windowsPathsNoEscape
|
|
2547
|
+
? s.replace(/[?*()[\]]/g, '[$&]')
|
|
2548
|
+
: s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
2549
|
+
};
|
|
2550
|
+
exports.escape = escape;
|
|
2551
|
+
//# sourceMappingURL=escape.js.map
|
|
2552
|
+
|
|
397
2553
|
/***/ })
|
|
398
2554
|
/******/ ]);
|
|
399
2555
|
/************************************************************************/
|
|
@@ -441,8 +2597,11 @@ const SCHEME = 'vscode-test-web';
|
|
|
441
2597
|
function activate(context) {
|
|
442
2598
|
const serverUri = context.extensionUri.with({ path: '/static/mount', query: undefined });
|
|
443
2599
|
const serverBackedRootDirectory = new ServerBackedDirectory(serverUri, [], '');
|
|
444
|
-
const
|
|
2600
|
+
const memFsProvider = new fsProvider_1.MemFileSystemProvider(SCHEME, serverBackedRootDirectory, context.extensionUri);
|
|
2601
|
+
const disposable = vscode_1.workspace.registerFileSystemProvider(SCHEME, memFsProvider);
|
|
445
2602
|
context.subscriptions.push(disposable);
|
|
2603
|
+
const searchDisposable = vscode_1.workspace.registerFileSearchProvider(SCHEME, memFsProvider);
|
|
2604
|
+
context.subscriptions.push(searchDisposable);
|
|
446
2605
|
console.log(`vscode-test-web-support fs provider registers for ${SCHEME}, initial content from ${serverUri.toString(/*skipEncoding*/ true)}`);
|
|
447
2606
|
}
|
|
448
2607
|
exports.activate = activate;
|