minimatch 8.0.2 → 8.0.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.
- package/README.md +9 -9
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/mjs/index.d.ts +2 -1
- package/dist/mjs/index.d.ts.map +1 -1
- package/dist/mjs/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/_parse.d.ts +0 -7
- package/dist/cjs/_parse.d.ts.map +0 -1
- package/dist/cjs/_parse.js +0 -300
- package/dist/cjs/_parse.js.map +0 -1
- package/dist/cjs/extglob.d.ts +0 -2
- package/dist/cjs/extglob.d.ts.map +0 -1
- package/dist/cjs/extglob.js +0 -4
- package/dist/cjs/extglob.js.map +0 -1
- package/dist/mjs/_parse.d.ts +0 -7
- package/dist/mjs/_parse.d.ts.map +0 -1
- package/dist/mjs/_parse.js +0 -296
- package/dist/mjs/_parse.js.map +0 -1
- package/dist/mjs/extglob.d.ts +0 -2
- package/dist/mjs/extglob.d.ts.map +0 -1
- package/dist/mjs/extglob.js +0 -3
- package/dist/mjs/extglob.js.map +0 -1
package/dist/cjs/_parse.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parse = void 0;
|
|
4
|
-
// parse a single path portion
|
|
5
|
-
const brace_expressions_js_1 = require("./brace-expressions.js");
|
|
6
|
-
const assert_valid_pattern_js_1 = require("./assert-valid-pattern.js");
|
|
7
|
-
const globUnescape = (s) => s.replace(/\\(.)/g, '$1');
|
|
8
|
-
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
9
|
-
// "abc" -> { a:true, b:true, c:true }
|
|
10
|
-
const charSet = (s) => s.split('').reduce((set, c) => {
|
|
11
|
-
set[c] = true;
|
|
12
|
-
return set;
|
|
13
|
-
}, {});
|
|
14
|
-
const plTypes = {
|
|
15
|
-
'!': { open: '(?:(?!(?:', close: '))[^/]*?)' },
|
|
16
|
-
'?': { open: '(?:', close: ')?' },
|
|
17
|
-
'+': { open: '(?:', close: ')+' },
|
|
18
|
-
'*': { open: '(?:', close: ')*' },
|
|
19
|
-
'@': { open: '(?:', close: ')' },
|
|
20
|
-
};
|
|
21
|
-
// characters that need to be escaped in RegExp.
|
|
22
|
-
const reSpecials = charSet('().*{}+?[]^$\\!');
|
|
23
|
-
// characters that indicate we have to add the pattern start
|
|
24
|
-
const addPatternStartSet = charSet('[.(');
|
|
25
|
-
// any single thing other than /
|
|
26
|
-
// don't need to escape / when using new RegExp()
|
|
27
|
-
const qmark = '[^/]';
|
|
28
|
-
// * => any number of characters
|
|
29
|
-
const star = qmark + '*?';
|
|
30
|
-
// TODO: take an offset and length, so we can sub-parse the extglobs
|
|
31
|
-
const parse = (options, pattern, debug) => {
|
|
32
|
-
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
|
|
33
|
-
if (pattern === '')
|
|
34
|
-
return '';
|
|
35
|
-
let re = '';
|
|
36
|
-
let hasMagic = false;
|
|
37
|
-
let escaping = false;
|
|
38
|
-
// ? => one single character
|
|
39
|
-
const patternListStack = [];
|
|
40
|
-
const negativeLists = [];
|
|
41
|
-
let stateChar = false;
|
|
42
|
-
let uflag = false;
|
|
43
|
-
let pl;
|
|
44
|
-
// . and .. never match anything that doesn't start with .,
|
|
45
|
-
// even when options.dot is set. However, if the pattern
|
|
46
|
-
// starts with ., then traversal patterns can match.
|
|
47
|
-
let dotTravAllowed = pattern.charAt(0) === '.';
|
|
48
|
-
let dotFileAllowed = options.dot || dotTravAllowed;
|
|
49
|
-
const patternStart = () => dotTravAllowed
|
|
50
|
-
? ''
|
|
51
|
-
: dotFileAllowed
|
|
52
|
-
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
53
|
-
: '(?!\\.)';
|
|
54
|
-
const subPatternStart = (p) => p.charAt(0) === '.'
|
|
55
|
-
? ''
|
|
56
|
-
: options.dot
|
|
57
|
-
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
58
|
-
: '(?!\\.)';
|
|
59
|
-
const clearStateChar = () => {
|
|
60
|
-
if (stateChar) {
|
|
61
|
-
// we had some state-tracking character
|
|
62
|
-
// that wasn't consumed by this pass.
|
|
63
|
-
switch (stateChar) {
|
|
64
|
-
case '*':
|
|
65
|
-
re += star;
|
|
66
|
-
hasMagic = true;
|
|
67
|
-
break;
|
|
68
|
-
case '?':
|
|
69
|
-
re += qmark;
|
|
70
|
-
hasMagic = true;
|
|
71
|
-
break;
|
|
72
|
-
default:
|
|
73
|
-
re += '\\' + stateChar;
|
|
74
|
-
break;
|
|
75
|
-
}
|
|
76
|
-
debug('clearStateChar %j %j', stateChar, re);
|
|
77
|
-
stateChar = false;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
for (let i = 0, c; i < pattern.length && (c = pattern.charAt(i)); i++) {
|
|
81
|
-
debug('%s\t%s %s %j', pattern, i, re, c);
|
|
82
|
-
// skip over any that are escaped.
|
|
83
|
-
if (escaping) {
|
|
84
|
-
// completely not allowed, even escaped.
|
|
85
|
-
// should be impossible.
|
|
86
|
-
/* c8 ignore start */
|
|
87
|
-
if (c === '/') {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
/* c8 ignore stop */
|
|
91
|
-
if (reSpecials[c]) {
|
|
92
|
-
re += '\\';
|
|
93
|
-
}
|
|
94
|
-
re += c;
|
|
95
|
-
escaping = false;
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
switch (c) {
|
|
99
|
-
// Should already be path-split by now.
|
|
100
|
-
/* c8 ignore start */
|
|
101
|
-
case '/': {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
/* c8 ignore stop */
|
|
105
|
-
case '\\':
|
|
106
|
-
clearStateChar();
|
|
107
|
-
escaping = true;
|
|
108
|
-
continue;
|
|
109
|
-
// the various stateChar values
|
|
110
|
-
// for the "extglob" stuff.
|
|
111
|
-
case '?':
|
|
112
|
-
case '*':
|
|
113
|
-
case '+':
|
|
114
|
-
case '@':
|
|
115
|
-
case '!':
|
|
116
|
-
debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
|
|
117
|
-
// if we already have a stateChar, then it means
|
|
118
|
-
// that there was something like ** or +? in there.
|
|
119
|
-
// Handle the stateChar, then proceed with this one.
|
|
120
|
-
debug('call clearStateChar %j', stateChar);
|
|
121
|
-
clearStateChar();
|
|
122
|
-
stateChar = c;
|
|
123
|
-
// if extglob is disabled, then +(asdf|foo) isn't a thing.
|
|
124
|
-
// just clear the statechar *now*, rather than even diving into
|
|
125
|
-
// the patternList stuff.
|
|
126
|
-
if (options.noext)
|
|
127
|
-
clearStateChar();
|
|
128
|
-
continue;
|
|
129
|
-
case '(': {
|
|
130
|
-
if (!stateChar) {
|
|
131
|
-
re += '\\(';
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
const plEntry = {
|
|
135
|
-
type: stateChar,
|
|
136
|
-
start: i - 1,
|
|
137
|
-
reStart: re.length,
|
|
138
|
-
open: plTypes[stateChar].open,
|
|
139
|
-
close: plTypes[stateChar].close,
|
|
140
|
-
};
|
|
141
|
-
debug(pattern, '\t', plEntry);
|
|
142
|
-
patternListStack.push(plEntry);
|
|
143
|
-
// negation is (?:(?!(?:js)(?:<rest>))[^/]*)
|
|
144
|
-
re += plEntry.open;
|
|
145
|
-
// next entry starts with a dot maybe?
|
|
146
|
-
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
147
|
-
dotTravAllowed = true;
|
|
148
|
-
re += subPatternStart(pattern.slice(i + 1));
|
|
149
|
-
}
|
|
150
|
-
debug('plType %j %j', stateChar, re);
|
|
151
|
-
stateChar = false;
|
|
152
|
-
continue;
|
|
153
|
-
}
|
|
154
|
-
case ')': {
|
|
155
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
|
156
|
-
if (!plEntry) {
|
|
157
|
-
re += '\\)';
|
|
158
|
-
continue;
|
|
159
|
-
}
|
|
160
|
-
patternListStack.pop();
|
|
161
|
-
// closing an extglob
|
|
162
|
-
clearStateChar();
|
|
163
|
-
hasMagic = true;
|
|
164
|
-
pl = plEntry;
|
|
165
|
-
// negation is (?:(?!js)[^/]*)
|
|
166
|
-
// The others are (?:<pattern>)<type>
|
|
167
|
-
re += pl.close;
|
|
168
|
-
if (pl.type === '!') {
|
|
169
|
-
negativeLists.push(Object.assign(pl, { reEnd: re.length }));
|
|
170
|
-
}
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
case '|': {
|
|
174
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
|
175
|
-
if (!plEntry) {
|
|
176
|
-
re += '\\|';
|
|
177
|
-
continue;
|
|
178
|
-
}
|
|
179
|
-
clearStateChar();
|
|
180
|
-
re += '|';
|
|
181
|
-
// next subpattern can start with a dot?
|
|
182
|
-
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
183
|
-
dotTravAllowed = true;
|
|
184
|
-
re += subPatternStart(pattern.slice(i + 1));
|
|
185
|
-
}
|
|
186
|
-
continue;
|
|
187
|
-
}
|
|
188
|
-
// these are mostly the same in regexp and glob
|
|
189
|
-
case '[':
|
|
190
|
-
// swallow any state-tracking char before the [
|
|
191
|
-
clearStateChar();
|
|
192
|
-
const [src, needUflag, consumed, magic] = (0, brace_expressions_js_1.parseClass)(pattern, i);
|
|
193
|
-
if (consumed) {
|
|
194
|
-
re += src;
|
|
195
|
-
uflag = uflag || needUflag;
|
|
196
|
-
i += consumed - 1;
|
|
197
|
-
hasMagic = hasMagic || magic;
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
re += '\\[';
|
|
201
|
-
}
|
|
202
|
-
continue;
|
|
203
|
-
case ']':
|
|
204
|
-
re += '\\' + c;
|
|
205
|
-
continue;
|
|
206
|
-
default:
|
|
207
|
-
// swallow any state char that wasn't consumed
|
|
208
|
-
clearStateChar();
|
|
209
|
-
re += regExpEscape(c);
|
|
210
|
-
break;
|
|
211
|
-
} // switch
|
|
212
|
-
} // for
|
|
213
|
-
// handle the case where we had a +( thing at the *end*
|
|
214
|
-
// of the pattern.
|
|
215
|
-
// each pattern list stack adds 3 chars, and we need to go through
|
|
216
|
-
// and escape any | chars that were passed through as-is for the regexp.
|
|
217
|
-
// Go through and escape them, taking care not to double-escape any
|
|
218
|
-
// | chars that were already escaped.
|
|
219
|
-
for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
|
|
220
|
-
let tail;
|
|
221
|
-
tail = re.slice(pl.reStart + pl.open.length);
|
|
222
|
-
debug(pattern, 'setting tail', re, pl);
|
|
223
|
-
// maybe some even number of \, then maybe 1 \, followed by a |
|
|
224
|
-
tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
|
|
225
|
-
if (!$2) {
|
|
226
|
-
// the | isn't already escaped, so escape it.
|
|
227
|
-
$2 = '\\';
|
|
228
|
-
// should already be done
|
|
229
|
-
/* c8 ignore start */
|
|
230
|
-
}
|
|
231
|
-
/* c8 ignore stop */
|
|
232
|
-
// need to escape all those slashes *again*, without escaping the
|
|
233
|
-
// one that we need for escaping the | character. As it works out,
|
|
234
|
-
// escaping an even number of slashes can be done by simply repeating
|
|
235
|
-
// it exactly after itself. That's why this trick works.
|
|
236
|
-
//
|
|
237
|
-
// I am sorry that you have to see this.
|
|
238
|
-
return $1 + $1 + $2 + '|';
|
|
239
|
-
});
|
|
240
|
-
debug('tail=%j\n %s', tail, tail, pl, re);
|
|
241
|
-
const t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
|
|
242
|
-
hasMagic = true;
|
|
243
|
-
re = re.slice(0, pl.reStart) + t + '\\(' + tail;
|
|
244
|
-
}
|
|
245
|
-
// handle trailing things that only matter at the very end.
|
|
246
|
-
clearStateChar();
|
|
247
|
-
if (escaping) {
|
|
248
|
-
// trailing \\
|
|
249
|
-
re += '\\\\';
|
|
250
|
-
}
|
|
251
|
-
// only need to apply the nodot start if the re starts with
|
|
252
|
-
// something that could conceivably capture a dot
|
|
253
|
-
const addPatternStart = addPatternStartSet[re.charAt(0)];
|
|
254
|
-
// Hack to work around lack of negative lookbehind in JS
|
|
255
|
-
// A pattern like: *.!(x).!(y|z) needs to ensure that a name
|
|
256
|
-
// like 'a.xyz.yz' doesn't match. So, the first negative
|
|
257
|
-
// lookahead, has to look ALL the way ahead, to the end of
|
|
258
|
-
// the pattern.
|
|
259
|
-
for (let n = negativeLists.length - 1; n > -1; n--) {
|
|
260
|
-
const nl = negativeLists[n];
|
|
261
|
-
const nlBefore = re.slice(0, nl.reStart);
|
|
262
|
-
const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
|
|
263
|
-
let nlAfter = re.slice(nl.reEnd);
|
|
264
|
-
const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
|
|
265
|
-
// Handle nested stuff like *(*.js|!(*.json)), where open parens
|
|
266
|
-
// mean that we should *not* include the ) in the bit that is considered
|
|
267
|
-
// "after" the negated section.
|
|
268
|
-
const closeParensBefore = nlBefore.split(')').length;
|
|
269
|
-
const openParensBefore = nlBefore.split('(').length - closeParensBefore;
|
|
270
|
-
let cleanAfter = nlAfter;
|
|
271
|
-
for (let i = 0; i < openParensBefore; i++) {
|
|
272
|
-
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
|
|
273
|
-
}
|
|
274
|
-
nlAfter = cleanAfter;
|
|
275
|
-
const dollar = nlAfter === '' ? '(?:$|\\/)' : '';
|
|
276
|
-
re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
|
|
277
|
-
}
|
|
278
|
-
// if the re is not "" at this point, then we need to make sure
|
|
279
|
-
// it doesn't match against an empty path part.
|
|
280
|
-
// Otherwise a/* will match a/, which it should not.
|
|
281
|
-
if (re !== '' && hasMagic) {
|
|
282
|
-
re = '(?=.)' + re;
|
|
283
|
-
}
|
|
284
|
-
if (addPatternStart) {
|
|
285
|
-
re = patternStart() + re;
|
|
286
|
-
}
|
|
287
|
-
// if it's nocase, and the lcase/uppercase don't match, it's magic
|
|
288
|
-
if (options.nocase && !hasMagic && !options.nocaseMagicOnly) {
|
|
289
|
-
hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
|
|
290
|
-
}
|
|
291
|
-
// skip the regexp for non-magical patterns
|
|
292
|
-
// unescape anything in it, though, so that it'll be
|
|
293
|
-
// an exact match against a file etc.
|
|
294
|
-
if (!hasMagic) {
|
|
295
|
-
return globUnescape(re);
|
|
296
|
-
}
|
|
297
|
-
return re;
|
|
298
|
-
};
|
|
299
|
-
exports.parse = parse;
|
|
300
|
-
//# sourceMappingURL=_parse.js.map
|
package/dist/cjs/_parse.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_parse.js","sourceRoot":"","sources":["../../src/_parse.ts"],"names":[],"mappings":";;;AAAA,8BAA8B;AAC9B,iEAAmD;AAEnD,uEAA8D;AAE9D,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AAC7D,MAAM,YAAY,GAAG,CAAC,CAAS,EAAE,EAAE,CACjC,CAAC,CAAC,OAAO,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAA;AAE/C,sCAAsC;AACtC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE,CAC5B,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAA6B,EAAE,CAAC,EAAE,EAAE;IACtD,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAA;IACb,OAAO,GAAG,CAAA;AACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AAER,MAAM,OAAO,GAAG;IACd,GAAG,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE;I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;SAChD;QACD,OAAO,GAAG,UAAU,CAAA;QAEpB,MAAM,MAAM,GAAG,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAA;QAEhD,EAAE,GAAG,QAAQ,GAAG,OAAO,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;KACpD;IAED,+DAA+D;IAC/D,+CAA+C;IAC/C,oDAAoD;IACpD,IAAI,EAAE,KAAK,EAAE,IAAI,QAAQ,EAAE;QACzB,EAAE,GAAG,OAAO,GAAG,EAAE,CAAA;KAClB;IAED,IAAI,eAAe,EAAE;QACnB,EAAE,GAAG,YAAY,EAAE,GAAG,EAAE,CAAA;KACzB;IAED,kEAAkE;IAClE,IAAI,OAAO,CAAC,MAAM,IAAI,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;QAC3D,QAAQ,GAAG,OAAO,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,WAAW,EAAE,CAAA;KAC3D;IAED,2CAA2C;IAC3C,oDAAoD;IACpD,qCAAqC;IACrC,IAAI,CAAC,QAAQ,EAAE;QACb,OAAO,YAAY,CAAC,EAAE,CAAC,CAAA;KACxB;IAED,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAtTY,QAAA,KAAK,SAsTjB","sourcesContent":["// parse a single path portion\nimport { parseClass } from './brace-expressions.js'\nimport { MinimatchOptions } from './index.js'\nimport { assertValidPattern } from './assert-valid-pattern.js'\n\nconst globUnescape = (s: string) => s.replace(/\\\\(.)/g, '$1')\nconst regExpEscape = (s: string) =>\n s.replace(/[-[\\]{}()*+?.,\\\\^$|#\\s]/g, '\\\\$&')\n\n// \"abc\" -> { a:true, b:true, c:true }\nconst charSet = (s: string) =>\n s.split('').reduce((set: { [k: string]: boolean }, c) => {\n set[c] = true\n return set\n }, {})\n\nconst plTypes = {\n '!': { open: '(?:(?!(?:', close: '))[^/]*?)' },\n '?': { open: '(?:', close: ')?' },\n '+': { open: '(?:', close: ')+' },\n '*': { open: '(?:', close: ')*' },\n '@': { open: '(?:', close: ')' },\n}\n\n// characters that need to be escaped in RegExp.\nconst reSpecials = charSet('().*{}+?[]^$\\\\!')\n\n// characters that indicate we have to add the pattern start\nconst addPatternStartSet = charSet('[.(')\n\ntype StateChar = '!' | '?' | '+' | '*' | '@'\n\n// any single thing other than /\n// don't need to escape / when using new RegExp()\nconst qmark = '[^/]'\n\n// * => any number of characters\nconst star = qmark + '*?'\n\ninterface PatternListEntry {\n type: string\n start: number\n reStart: number\n open: string\n close: string\n}\n\ninterface NegativePatternListEntry extends PatternListEntry {\n reEnd: number\n}\n\nexport type MMRegExp = RegExp & {\n _src?: string\n _glob?: string\n}\n\n// TODO: take an offset and length, so we can sub-parse the extglobs\nexport const parse = (\n options: MinimatchOptions,\n pattern: string,\n debug: (...a: any[]) => void,\n): false | string => {\n assertValidPattern(pattern)\n\n if (pattern === '') return ''\n\n let re = ''\n let hasMagic = false\n let escaping = false\n // ? => one single character\n const patternListStack: PatternListEntry[] = []\n const negativeLists: NegativePatternListEntry[] = []\n let stateChar: StateChar | false = false\n let uflag = false\n let pl: PatternListEntry | undefined\n // . and .. never match anything that doesn't start with .,\n // even when options.dot is set. However, if the pattern\n // starts with ., then traversal patterns can match.\n let dotTravAllowed = pattern.charAt(0) === '.'\n let dotFileAllowed = options.dot || dotTravAllowed\n const patternStart = () =>\n dotTravAllowed\n ? ''\n : dotFileAllowed\n ? '(?!(?:^|\\\\/)\\\\.{1,2}(?:$|\\\\/))'\n : '(?!\\\\.)'\n const subPatternStart = (p: string) =>\n p.charAt(0) === '.'\n ? ''\n : options.dot\n ? '(?!(?:^|\\\\/)\\\\.{1,2}(?:$|\\\\/))'\n : '(?!\\\\.)'\n\n const clearStateChar = () => {\n if (stateChar) {\n // we had some state-tracking character\n // that wasn't consumed by this pass.\n switch (stateChar) {\n case '*':\n re += star\n hasMagic = true\n break\n case '?':\n re += qmark\n hasMagic = true\n break\n default:\n re += '\\\\' + stateChar\n break\n }\n debug('clearStateChar %j %j', stateChar, re)\n stateChar = false\n }\n }\n\n for (\n let i = 0, c: string;\n i < pattern.length && (c = pattern.charAt(i));\n i++\n ) {\n debug('%s\\t%s %s %j', pattern, i, re, c)\n\n // skip over any that are escaped.\n if (escaping) {\n // completely not allowed, even escaped.\n // should be impossible.\n /* c8 ignore start */\n if (c === '/') {\n return false\n }\n /* c8 ignore stop */\n\n if (reSpecials[c]) {\n re += '\\\\'\n }\n re += c\n escaping = false\n continue\n }\n\n switch (c) {\n // Should already be path-split by now.\n /* c8 ignore start */\n case '/': {\n return false\n }\n /* c8 ignore stop */\n\n case '\\\\':\n clearStateChar()\n escaping = true\n continue\n\n // the various stateChar values\n // for the \"extglob\" stuff.\n case '?':\n case '*':\n case '+':\n case '@':\n case '!':\n debug('%s\\t%s %s %j <-- stateChar', pattern, i, re, c)\n\n // if we already have a stateChar, then it means\n // that there was something like ** or +? in there.\n // Handle the stateChar, then proceed with this one.\n debug('call clearStateChar %j', stateChar)\n clearStateChar()\n stateChar = c\n // if extglob is disabled, then +(asdf|foo) isn't a thing.\n // just clear the statechar *now*, rather than even diving into\n // the patternList stuff.\n if (options.noext) clearStateChar()\n continue\n\n case '(': {\n if (!stateChar) {\n re += '\\\\('\n continue\n }\n\n const plEntry: PatternListEntry = {\n type: stateChar,\n start: i - 1,\n reStart: re.length,\n open: plTypes[stateChar].open,\n close: plTypes[stateChar].close,\n }\n debug(pattern, '\\t', plEntry)\n patternListStack.push(plEntry)\n // negation is (?:(?!(?:js)(?:<rest>))[^/]*)\n re += plEntry.open\n // next entry starts with a dot maybe?\n if (plEntry.start === 0 && plEntry.type !== '!') {\n dotTravAllowed = true\n re += subPatternStart(pattern.slice(i + 1))\n }\n debug('plType %j %j', stateChar, re)\n stateChar = false\n continue\n }\n\n case ')': {\n const plEntry = patternListStack[patternListStack.length - 1]\n if (!plEntry) {\n re += '\\\\)'\n continue\n }\n patternListStack.pop()\n\n // closing an extglob\n clearStateChar()\n hasMagic = true\n pl = plEntry\n // negation is (?:(?!js)[^/]*)\n // The others are (?:<pattern>)<type>\n re += pl.close\n if (pl.type === '!') {\n negativeLists.push(Object.assign(pl, { reEnd: re.length }))\n }\n continue\n }\n\n case '|': {\n const plEntry = patternListStack[patternListStack.length - 1]\n if (!plEntry) {\n re += '\\\\|'\n continue\n }\n\n clearStateChar()\n re += '|'\n // next subpattern can start with a dot?\n if (plEntry.start === 0 && plEntry.type !== '!') {\n dotTravAllowed = true\n re += subPatternStart(pattern.slice(i + 1))\n }\n continue\n }\n\n // these are mostly the same in regexp and glob\n case '[':\n // swallow any state-tracking char before the [\n clearStateChar()\n const [src, needUflag, consumed, magic] = parseClass(pattern, i)\n if (consumed) {\n re += src\n uflag = uflag || needUflag\n i += consumed - 1\n hasMagic = hasMagic || magic\n } else {\n re += '\\\\['\n }\n continue\n\n case ']':\n re += '\\\\' + c\n continue\n\n default:\n // swallow any state char that wasn't consumed\n clearStateChar()\n\n re += regExpEscape(c)\n break\n } // switch\n } // for\n\n // handle the case where we had a +( thing at the *end*\n // of the pattern.\n // each pattern list stack adds 3 chars, and we need to go through\n // and escape any | chars that were passed through as-is for the regexp.\n // Go through and escape them, taking care not to double-escape any\n // | chars that were already escaped.\n for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {\n let tail: string\n tail = re.slice(pl.reStart + pl.open.length)\n debug(pattern, 'setting tail', re, pl)\n // maybe some even number of \\, then maybe 1 \\, followed by a |\n tail = tail.replace(/((?:\\\\{2}){0,64})(\\\\?)\\|/g, (_, $1, $2) => {\n if (!$2) {\n // the | isn't already escaped, so escape it.\n $2 = '\\\\'\n // should already be done\n /* c8 ignore start */\n }\n /* c8 ignore stop */\n\n // need to escape all those slashes *again*, without escaping the\n // one that we need for escaping the | character. As it works out,\n // escaping an even number of slashes can be done by simply repeating\n // it exactly after itself. That's why this trick works.\n //\n // I am sorry that you have to see this.\n return $1 + $1 + $2 + '|'\n })\n\n debug('tail=%j\\n %s', tail, tail, pl, re)\n const t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\\\' + pl.type\n\n hasMagic = true\n re = re.slice(0, pl.reStart) + t + '\\\\(' + tail\n }\n\n // handle trailing things that only matter at the very end.\n clearStateChar()\n if (escaping) {\n // trailing \\\\\n re += '\\\\\\\\'\n }\n\n // only need to apply the nodot start if the re starts with\n // something that could conceivably capture a dot\n const addPatternStart = addPatternStartSet[re.charAt(0)]\n\n // Hack to work around lack of negative lookbehind in JS\n // A pattern like: *.!(x).!(y|z) needs to ensure that a name\n // like 'a.xyz.yz' doesn't match. So, the first negative\n // lookahead, has to look ALL the way ahead, to the end of\n // the pattern.\n for (let n = negativeLists.length - 1; n > -1; n--) {\n const nl = negativeLists[n]\n\n const nlBefore = re.slice(0, nl.reStart)\n const nlFirst = re.slice(nl.reStart, nl.reEnd - 8)\n let nlAfter = re.slice(nl.reEnd)\n const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter\n\n // Handle nested stuff like *(*.js|!(*.json)), where open parens\n // mean that we should *not* include the ) in the bit that is considered\n // \"after\" the negated section.\n const closeParensBefore = nlBefore.split(')').length\n const openParensBefore = nlBefore.split('(').length - closeParensBefore\n let cleanAfter = nlAfter\n for (let i = 0; i < openParensBefore; i++) {\n cleanAfter = cleanAfter.replace(/\\)[+*?]?/, '')\n }\n nlAfter = cleanAfter\n\n const dollar = nlAfter === '' ? '(?:$|\\\\/)' : ''\n\n re = nlBefore + nlFirst + nlAfter + dollar + nlLast\n }\n\n // if the re is not \"\" at this point, then we need to make sure\n // it doesn't match against an empty path part.\n // Otherwise a/* will match a/, which it should not.\n if (re !== '' && hasMagic) {\n re = '(?=.)' + re\n }\n\n if (addPatternStart) {\n re = patternStart() + re\n }\n\n // if it's nocase, and the lcase/uppercase don't match, it's magic\n if (options.nocase && !hasMagic && !options.nocaseMagicOnly) {\n hasMagic = pattern.toUpperCase() !== pattern.toLowerCase()\n }\n\n // skip the regexp for non-magical patterns\n // unescape anything in it, though, so that it'll be\n // an exact match against a file etc.\n if (!hasMagic) {\n return globUnescape(re)\n }\n\n return re\n}\n"]}
|
package/dist/cjs/extglob.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extglob.d.ts","sourceRoot":"","sources":["../../src/extglob.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,CAAA"}
|
package/dist/cjs/extglob.js
DELETED
package/dist/cjs/extglob.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"extglob.js","sourceRoot":"","sources":["../../src/extglob.ts"],"names":[],"mappings":";AAAA,iDAAiD","sourcesContent":["// translate an extglob into a regular expression\n\n// call into this when we get a [!?@+] followed by (\n// Walk down until we find the appropriate closing ),\n// and parse all the sections.\n\n\nexport {}\n"]}
|
package/dist/mjs/_parse.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { MinimatchOptions } from './index.js';
|
|
2
|
-
export type MMRegExp = RegExp & {
|
|
3
|
-
_src?: string;
|
|
4
|
-
_glob?: string;
|
|
5
|
-
};
|
|
6
|
-
export declare const parse: (options: MinimatchOptions, pattern: string, debug: (...a: any[]) => void) => false | string;
|
|
7
|
-
//# sourceMappingURL=_parse.d.ts.map
|
package/dist/mjs/_parse.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_parse.d.ts","sourceRoot":"","sources":["../../src/_parse.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAiD7C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAGD,eAAO,MAAM,KAAK,YACP,gBAAgB,WAChB,MAAM,gBACD,GAAG,EAAE,KAAK,IAAI,KAC3B,KAAK,GAAG,MAkTV,CAAA"}
|
package/dist/mjs/_parse.js
DELETED
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
// parse a single path portion
|
|
2
|
-
import { parseClass } from './brace-expressions.js';
|
|
3
|
-
import { assertValidPattern } from './assert-valid-pattern.js';
|
|
4
|
-
const globUnescape = (s) => s.replace(/\\(.)/g, '$1');
|
|
5
|
-
const regExpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
|
6
|
-
// "abc" -> { a:true, b:true, c:true }
|
|
7
|
-
const charSet = (s) => s.split('').reduce((set, c) => {
|
|
8
|
-
set[c] = true;
|
|
9
|
-
return set;
|
|
10
|
-
}, {});
|
|
11
|
-
const plTypes = {
|
|
12
|
-
'!': { open: '(?:(?!(?:', close: '))[^/]*?)' },
|
|
13
|
-
'?': { open: '(?:', close: ')?' },
|
|
14
|
-
'+': { open: '(?:', close: ')+' },
|
|
15
|
-
'*': { open: '(?:', close: ')*' },
|
|
16
|
-
'@': { open: '(?:', close: ')' },
|
|
17
|
-
};
|
|
18
|
-
// characters that need to be escaped in RegExp.
|
|
19
|
-
const reSpecials = charSet('().*{}+?[]^$\\!');
|
|
20
|
-
// characters that indicate we have to add the pattern start
|
|
21
|
-
const addPatternStartSet = charSet('[.(');
|
|
22
|
-
// any single thing other than /
|
|
23
|
-
// don't need to escape / when using new RegExp()
|
|
24
|
-
const qmark = '[^/]';
|
|
25
|
-
// * => any number of characters
|
|
26
|
-
const star = qmark + '*?';
|
|
27
|
-
// TODO: take an offset and length, so we can sub-parse the extglobs
|
|
28
|
-
export const parse = (options, pattern, debug) => {
|
|
29
|
-
assertValidPattern(pattern);
|
|
30
|
-
if (pattern === '')
|
|
31
|
-
return '';
|
|
32
|
-
let re = '';
|
|
33
|
-
let hasMagic = false;
|
|
34
|
-
let escaping = false;
|
|
35
|
-
// ? => one single character
|
|
36
|
-
const patternListStack = [];
|
|
37
|
-
const negativeLists = [];
|
|
38
|
-
let stateChar = false;
|
|
39
|
-
let uflag = false;
|
|
40
|
-
let pl;
|
|
41
|
-
// . and .. never match anything that doesn't start with .,
|
|
42
|
-
// even when options.dot is set. However, if the pattern
|
|
43
|
-
// starts with ., then traversal patterns can match.
|
|
44
|
-
let dotTravAllowed = pattern.charAt(0) === '.';
|
|
45
|
-
let dotFileAllowed = options.dot || dotTravAllowed;
|
|
46
|
-
const patternStart = () => dotTravAllowed
|
|
47
|
-
? ''
|
|
48
|
-
: dotFileAllowed
|
|
49
|
-
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
50
|
-
: '(?!\\.)';
|
|
51
|
-
const subPatternStart = (p) => p.charAt(0) === '.'
|
|
52
|
-
? ''
|
|
53
|
-
: options.dot
|
|
54
|
-
? '(?!(?:^|\\/)\\.{1,2}(?:$|\\/))'
|
|
55
|
-
: '(?!\\.)';
|
|
56
|
-
const clearStateChar = () => {
|
|
57
|
-
if (stateChar) {
|
|
58
|
-
// we had some state-tracking character
|
|
59
|
-
// that wasn't consumed by this pass.
|
|
60
|
-
switch (stateChar) {
|
|
61
|
-
case '*':
|
|
62
|
-
re += star;
|
|
63
|
-
hasMagic = true;
|
|
64
|
-
break;
|
|
65
|
-
case '?':
|
|
66
|
-
re += qmark;
|
|
67
|
-
hasMagic = true;
|
|
68
|
-
break;
|
|
69
|
-
default:
|
|
70
|
-
re += '\\' + stateChar;
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
debug('clearStateChar %j %j', stateChar, re);
|
|
74
|
-
stateChar = false;
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
for (let i = 0, c; i < pattern.length && (c = pattern.charAt(i)); i++) {
|
|
78
|
-
debug('%s\t%s %s %j', pattern, i, re, c);
|
|
79
|
-
// skip over any that are escaped.
|
|
80
|
-
if (escaping) {
|
|
81
|
-
// completely not allowed, even escaped.
|
|
82
|
-
// should be impossible.
|
|
83
|
-
/* c8 ignore start */
|
|
84
|
-
if (c === '/') {
|
|
85
|
-
return false;
|
|
86
|
-
}
|
|
87
|
-
/* c8 ignore stop */
|
|
88
|
-
if (reSpecials[c]) {
|
|
89
|
-
re += '\\';
|
|
90
|
-
}
|
|
91
|
-
re += c;
|
|
92
|
-
escaping = false;
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
switch (c) {
|
|
96
|
-
// Should already be path-split by now.
|
|
97
|
-
/* c8 ignore start */
|
|
98
|
-
case '/': {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
/* c8 ignore stop */
|
|
102
|
-
case '\\':
|
|
103
|
-
clearStateChar();
|
|
104
|
-
escaping = true;
|
|
105
|
-
continue;
|
|
106
|
-
// the various stateChar values
|
|
107
|
-
// for the "extglob" stuff.
|
|
108
|
-
case '?':
|
|
109
|
-
case '*':
|
|
110
|
-
case '+':
|
|
111
|
-
case '@':
|
|
112
|
-
case '!':
|
|
113
|
-
debug('%s\t%s %s %j <-- stateChar', pattern, i, re, c);
|
|
114
|
-
// if we already have a stateChar, then it means
|
|
115
|
-
// that there was something like ** or +? in there.
|
|
116
|
-
// Handle the stateChar, then proceed with this one.
|
|
117
|
-
debug('call clearStateChar %j', stateChar);
|
|
118
|
-
clearStateChar();
|
|
119
|
-
stateChar = c;
|
|
120
|
-
// if extglob is disabled, then +(asdf|foo) isn't a thing.
|
|
121
|
-
// just clear the statechar *now*, rather than even diving into
|
|
122
|
-
// the patternList stuff.
|
|
123
|
-
if (options.noext)
|
|
124
|
-
clearStateChar();
|
|
125
|
-
continue;
|
|
126
|
-
case '(': {
|
|
127
|
-
if (!stateChar) {
|
|
128
|
-
re += '\\(';
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
const plEntry = {
|
|
132
|
-
type: stateChar,
|
|
133
|
-
start: i - 1,
|
|
134
|
-
reStart: re.length,
|
|
135
|
-
open: plTypes[stateChar].open,
|
|
136
|
-
close: plTypes[stateChar].close,
|
|
137
|
-
};
|
|
138
|
-
debug(pattern, '\t', plEntry);
|
|
139
|
-
patternListStack.push(plEntry);
|
|
140
|
-
// negation is (?:(?!(?:js)(?:<rest>))[^/]*)
|
|
141
|
-
re += plEntry.open;
|
|
142
|
-
// next entry starts with a dot maybe?
|
|
143
|
-
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
144
|
-
dotTravAllowed = true;
|
|
145
|
-
re += subPatternStart(pattern.slice(i + 1));
|
|
146
|
-
}
|
|
147
|
-
debug('plType %j %j', stateChar, re);
|
|
148
|
-
stateChar = false;
|
|
149
|
-
continue;
|
|
150
|
-
}
|
|
151
|
-
case ')': {
|
|
152
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
|
153
|
-
if (!plEntry) {
|
|
154
|
-
re += '\\)';
|
|
155
|
-
continue;
|
|
156
|
-
}
|
|
157
|
-
patternListStack.pop();
|
|
158
|
-
// closing an extglob
|
|
159
|
-
clearStateChar();
|
|
160
|
-
hasMagic = true;
|
|
161
|
-
pl = plEntry;
|
|
162
|
-
// negation is (?:(?!js)[^/]*)
|
|
163
|
-
// The others are (?:<pattern>)<type>
|
|
164
|
-
re += pl.close;
|
|
165
|
-
if (pl.type === '!') {
|
|
166
|
-
negativeLists.push(Object.assign(pl, { reEnd: re.length }));
|
|
167
|
-
}
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
case '|': {
|
|
171
|
-
const plEntry = patternListStack[patternListStack.length - 1];
|
|
172
|
-
if (!plEntry) {
|
|
173
|
-
re += '\\|';
|
|
174
|
-
continue;
|
|
175
|
-
}
|
|
176
|
-
clearStateChar();
|
|
177
|
-
re += '|';
|
|
178
|
-
// next subpattern can start with a dot?
|
|
179
|
-
if (plEntry.start === 0 && plEntry.type !== '!') {
|
|
180
|
-
dotTravAllowed = true;
|
|
181
|
-
re += subPatternStart(pattern.slice(i + 1));
|
|
182
|
-
}
|
|
183
|
-
continue;
|
|
184
|
-
}
|
|
185
|
-
// these are mostly the same in regexp and glob
|
|
186
|
-
case '[':
|
|
187
|
-
// swallow any state-tracking char before the [
|
|
188
|
-
clearStateChar();
|
|
189
|
-
const [src, needUflag, consumed, magic] = parseClass(pattern, i);
|
|
190
|
-
if (consumed) {
|
|
191
|
-
re += src;
|
|
192
|
-
uflag = uflag || needUflag;
|
|
193
|
-
i += consumed - 1;
|
|
194
|
-
hasMagic = hasMagic || magic;
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
re += '\\[';
|
|
198
|
-
}
|
|
199
|
-
continue;
|
|
200
|
-
case ']':
|
|
201
|
-
re += '\\' + c;
|
|
202
|
-
continue;
|
|
203
|
-
default:
|
|
204
|
-
// swallow any state char that wasn't consumed
|
|
205
|
-
clearStateChar();
|
|
206
|
-
re += regExpEscape(c);
|
|
207
|
-
break;
|
|
208
|
-
} // switch
|
|
209
|
-
} // for
|
|
210
|
-
// handle the case where we had a +( thing at the *end*
|
|
211
|
-
// of the pattern.
|
|
212
|
-
// each pattern list stack adds 3 chars, and we need to go through
|
|
213
|
-
// and escape any | chars that were passed through as-is for the regexp.
|
|
214
|
-
// Go through and escape them, taking care not to double-escape any
|
|
215
|
-
// | chars that were already escaped.
|
|
216
|
-
for (pl = patternListStack.pop(); pl; pl = patternListStack.pop()) {
|
|
217
|
-
let tail;
|
|
218
|
-
tail = re.slice(pl.reStart + pl.open.length);
|
|
219
|
-
debug(pattern, 'setting tail', re, pl);
|
|
220
|
-
// maybe some even number of \, then maybe 1 \, followed by a |
|
|
221
|
-
tail = tail.replace(/((?:\\{2}){0,64})(\\?)\|/g, (_, $1, $2) => {
|
|
222
|
-
if (!$2) {
|
|
223
|
-
// the | isn't already escaped, so escape it.
|
|
224
|
-
$2 = '\\';
|
|
225
|
-
// should already be done
|
|
226
|
-
/* c8 ignore start */
|
|
227
|
-
}
|
|
228
|
-
/* c8 ignore stop */
|
|
229
|
-
// need to escape all those slashes *again*, without escaping the
|
|
230
|
-
// one that we need for escaping the | character. As it works out,
|
|
231
|
-
// escaping an even number of slashes can be done by simply repeating
|
|
232
|
-
// it exactly after itself. That's why this trick works.
|
|
233
|
-
//
|
|
234
|
-
// I am sorry that you have to see this.
|
|
235
|
-
return $1 + $1 + $2 + '|';
|
|
236
|
-
});
|
|
237
|
-
debug('tail=%j\n %s', tail, tail, pl, re);
|
|
238
|
-
const t = pl.type === '*' ? star : pl.type === '?' ? qmark : '\\' + pl.type;
|
|
239
|
-
hasMagic = true;
|
|
240
|
-
re = re.slice(0, pl.reStart) + t + '\\(' + tail;
|
|
241
|
-
}
|
|
242
|
-
// handle trailing things that only matter at the very end.
|
|
243
|
-
clearStateChar();
|
|
244
|
-
if (escaping) {
|
|
245
|
-
// trailing \\
|
|
246
|
-
re += '\\\\';
|
|
247
|
-
}
|
|
248
|
-
// only need to apply the nodot start if the re starts with
|
|
249
|
-
// something that could conceivably capture a dot
|
|
250
|
-
const addPatternStart = addPatternStartSet[re.charAt(0)];
|
|
251
|
-
// Hack to work around lack of negative lookbehind in JS
|
|
252
|
-
// A pattern like: *.!(x).!(y|z) needs to ensure that a name
|
|
253
|
-
// like 'a.xyz.yz' doesn't match. So, the first negative
|
|
254
|
-
// lookahead, has to look ALL the way ahead, to the end of
|
|
255
|
-
// the pattern.
|
|
256
|
-
for (let n = negativeLists.length - 1; n > -1; n--) {
|
|
257
|
-
const nl = negativeLists[n];
|
|
258
|
-
const nlBefore = re.slice(0, nl.reStart);
|
|
259
|
-
const nlFirst = re.slice(nl.reStart, nl.reEnd - 8);
|
|
260
|
-
let nlAfter = re.slice(nl.reEnd);
|
|
261
|
-
const nlLast = re.slice(nl.reEnd - 8, nl.reEnd) + nlAfter;
|
|
262
|
-
// Handle nested stuff like *(*.js|!(*.json)), where open parens
|
|
263
|
-
// mean that we should *not* include the ) in the bit that is considered
|
|
264
|
-
// "after" the negated section.
|
|
265
|
-
const closeParensBefore = nlBefore.split(')').length;
|
|
266
|
-
const openParensBefore = nlBefore.split('(').length - closeParensBefore;
|
|
267
|
-
let cleanAfter = nlAfter;
|
|
268
|
-
for (let i = 0; i < openParensBefore; i++) {
|
|
269
|
-
cleanAfter = cleanAfter.replace(/\)[+*?]?/, '');
|
|
270
|
-
}
|
|
271
|
-
nlAfter = cleanAfter;
|
|
272
|
-
const dollar = nlAfter === '' ? '(?:$|\\/)' : '';
|
|
273
|
-
re = nlBefore + nlFirst + nlAfter + dollar + nlLast;
|
|
274
|
-
}
|
|
275
|
-
// if the re is not "" at this point, then we need to make sure
|
|
276
|
-
// it doesn't match against an empty path part.
|
|
277
|
-
// Otherwise a/* will match a/, which it should not.
|
|
278
|
-
if (re !== '' && hasMagic) {
|
|
279
|
-
re = '(?=.)' + re;
|
|
280
|
-
}
|
|
281
|
-
if (addPatternStart) {
|
|
282
|
-
re = patternStart() + re;
|
|
283
|
-
}
|
|
284
|
-
// if it's nocase, and the lcase/uppercase don't match, it's magic
|
|
285
|
-
if (options.nocase && !hasMagic && !options.nocaseMagicOnly) {
|
|
286
|
-
hasMagic = pattern.toUpperCase() !== pattern.toLowerCase();
|
|
287
|
-
}
|
|
288
|
-
// skip the regexp for non-magical patterns
|
|
289
|
-
// unescape anything in it, though, so that it'll be
|
|
290
|
-
// an exact match against a file etc.
|
|
291
|
-
if (!hasMagic) {
|
|
292
|
-
return globUnescape(re);
|
|
293
|
-
}
|
|
294
|
-
return re;
|
|
295
|
-
};
|
|
296
|
-
//# sourceMappingURL=_parse.js.map
|