@rslib/core 0.20.0 → 0.20.1
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/compiled/rslog/index.d.ts +18 -2
- package/compiled/rslog/package.json +1 -1
- package/dist/chokidar.js +1467 -0
- package/dist/chokidar.js.LICENSE.txt +1 -0
- package/dist/index.js +375 -80
- package/dist/rslib-runtime.js +18 -0
- package/dist/tinyglobby.js +2177 -0
- package/dist-types/config.d.ts +6 -1
- package/dist-types/css/cssConfig.d.ts +2 -2
- package/dist-types/utils/color.d.ts +1 -2
- package/dist-types/utils/helper.d.ts +1 -1
- package/package.json +13 -14
- package/compiled/chokidar/index.d.ts +0 -346
- package/compiled/chokidar/index.js +0 -1778
- package/compiled/chokidar/license +0 -21
- package/compiled/chokidar/package.json +0 -1
- package/compiled/picocolors/index.d.ts +0 -55
- package/compiled/picocolors/index.js +0 -132
- package/compiled/picocolors/license +0 -15
- package/compiled/picocolors/package.json +0 -1
- package/compiled/rslog/index.js +0 -300
- package/compiled/tinyglobby/index.d.ts +0 -46
- package/compiled/tinyglobby/index.js +0 -3061
- package/compiled/tinyglobby/license +0 -21
- package/compiled/tinyglobby/package.json +0 -1
|
@@ -1,3061 +0,0 @@
|
|
|
1
|
-
/******/ (() => { // webpackBootstrap
|
|
2
|
-
/******/ var __webpack_modules__ = ({
|
|
3
|
-
|
|
4
|
-
/***/ 676:
|
|
5
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const pico = __nccwpck_require__(582);
|
|
11
|
-
const utils = __nccwpck_require__(473);
|
|
12
|
-
|
|
13
|
-
function picomatch(glob, options, returnState = false) {
|
|
14
|
-
// default to os.platform()
|
|
15
|
-
if (options && (options.windows === null || options.windows === undefined)) {
|
|
16
|
-
// don't mutate the original options object
|
|
17
|
-
options = { ...options, windows: utils.isWindows() };
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return pico(glob, options, returnState);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
Object.assign(picomatch, pico);
|
|
24
|
-
module.exports = picomatch;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/***/ }),
|
|
28
|
-
|
|
29
|
-
/***/ 717:
|
|
30
|
-
/***/ ((module) => {
|
|
31
|
-
|
|
32
|
-
"use strict";
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const WIN_SLASH = '\\\\/';
|
|
36
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Posix glob regex
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
const DOT_LITERAL = '\\.';
|
|
43
|
-
const PLUS_LITERAL = '\\+';
|
|
44
|
-
const QMARK_LITERAL = '\\?';
|
|
45
|
-
const SLASH_LITERAL = '\\/';
|
|
46
|
-
const ONE_CHAR = '(?=.)';
|
|
47
|
-
const QMARK = '[^/]';
|
|
48
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
49
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
50
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
51
|
-
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
52
|
-
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
53
|
-
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
54
|
-
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
55
|
-
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
56
|
-
const STAR = `${QMARK}*?`;
|
|
57
|
-
const SEP = '/';
|
|
58
|
-
|
|
59
|
-
const POSIX_CHARS = {
|
|
60
|
-
DOT_LITERAL,
|
|
61
|
-
PLUS_LITERAL,
|
|
62
|
-
QMARK_LITERAL,
|
|
63
|
-
SLASH_LITERAL,
|
|
64
|
-
ONE_CHAR,
|
|
65
|
-
QMARK,
|
|
66
|
-
END_ANCHOR,
|
|
67
|
-
DOTS_SLASH,
|
|
68
|
-
NO_DOT,
|
|
69
|
-
NO_DOTS,
|
|
70
|
-
NO_DOT_SLASH,
|
|
71
|
-
NO_DOTS_SLASH,
|
|
72
|
-
QMARK_NO_DOT,
|
|
73
|
-
STAR,
|
|
74
|
-
START_ANCHOR,
|
|
75
|
-
SEP
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Windows glob regex
|
|
80
|
-
*/
|
|
81
|
-
|
|
82
|
-
const WINDOWS_CHARS = {
|
|
83
|
-
...POSIX_CHARS,
|
|
84
|
-
|
|
85
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
86
|
-
QMARK: WIN_NO_SLASH,
|
|
87
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
88
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
89
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
90
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
91
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
92
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
93
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
94
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
95
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
96
|
-
SEP: '\\'
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* POSIX Bracket Regex
|
|
101
|
-
*/
|
|
102
|
-
|
|
103
|
-
const POSIX_REGEX_SOURCE = {
|
|
104
|
-
alnum: 'a-zA-Z0-9',
|
|
105
|
-
alpha: 'a-zA-Z',
|
|
106
|
-
ascii: '\\x00-\\x7F',
|
|
107
|
-
blank: ' \\t',
|
|
108
|
-
cntrl: '\\x00-\\x1F\\x7F',
|
|
109
|
-
digit: '0-9',
|
|
110
|
-
graph: '\\x21-\\x7E',
|
|
111
|
-
lower: 'a-z',
|
|
112
|
-
print: '\\x20-\\x7E ',
|
|
113
|
-
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
114
|
-
space: ' \\t\\r\\n\\v\\f',
|
|
115
|
-
upper: 'A-Z',
|
|
116
|
-
word: 'A-Za-z0-9_',
|
|
117
|
-
xdigit: 'A-Fa-f0-9'
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
module.exports = {
|
|
121
|
-
MAX_LENGTH: 1024 * 64,
|
|
122
|
-
POSIX_REGEX_SOURCE,
|
|
123
|
-
|
|
124
|
-
// regular expressions
|
|
125
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
126
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
127
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
128
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
129
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
130
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
131
|
-
|
|
132
|
-
// Replace globs with equivalent patterns to reduce parsing time.
|
|
133
|
-
REPLACEMENTS: {
|
|
134
|
-
__proto__: null,
|
|
135
|
-
'***': '*',
|
|
136
|
-
'**/**': '**',
|
|
137
|
-
'**/**/**': '**'
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
// Digits
|
|
141
|
-
CHAR_0: 48, /* 0 */
|
|
142
|
-
CHAR_9: 57, /* 9 */
|
|
143
|
-
|
|
144
|
-
// Alphabet chars.
|
|
145
|
-
CHAR_UPPERCASE_A: 65, /* A */
|
|
146
|
-
CHAR_LOWERCASE_A: 97, /* a */
|
|
147
|
-
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
148
|
-
CHAR_LOWERCASE_Z: 122, /* z */
|
|
149
|
-
|
|
150
|
-
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
151
|
-
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
152
|
-
|
|
153
|
-
CHAR_ASTERISK: 42, /* * */
|
|
154
|
-
|
|
155
|
-
// Non-alphabetic chars.
|
|
156
|
-
CHAR_AMPERSAND: 38, /* & */
|
|
157
|
-
CHAR_AT: 64, /* @ */
|
|
158
|
-
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
159
|
-
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
160
|
-
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
161
|
-
CHAR_COLON: 58, /* : */
|
|
162
|
-
CHAR_COMMA: 44, /* , */
|
|
163
|
-
CHAR_DOT: 46, /* . */
|
|
164
|
-
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
165
|
-
CHAR_EQUAL: 61, /* = */
|
|
166
|
-
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
167
|
-
CHAR_FORM_FEED: 12, /* \f */
|
|
168
|
-
CHAR_FORWARD_SLASH: 47, /* / */
|
|
169
|
-
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
170
|
-
CHAR_HASH: 35, /* # */
|
|
171
|
-
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
172
|
-
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
173
|
-
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
174
|
-
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
175
|
-
CHAR_LINE_FEED: 10, /* \n */
|
|
176
|
-
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
177
|
-
CHAR_PERCENT: 37, /* % */
|
|
178
|
-
CHAR_PLUS: 43, /* + */
|
|
179
|
-
CHAR_QUESTION_MARK: 63, /* ? */
|
|
180
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
181
|
-
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
182
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
183
|
-
CHAR_SEMICOLON: 59, /* ; */
|
|
184
|
-
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
185
|
-
CHAR_SPACE: 32, /* */
|
|
186
|
-
CHAR_TAB: 9, /* \t */
|
|
187
|
-
CHAR_UNDERSCORE: 95, /* _ */
|
|
188
|
-
CHAR_VERTICAL_LINE: 124, /* | */
|
|
189
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Create EXTGLOB_CHARS
|
|
193
|
-
*/
|
|
194
|
-
|
|
195
|
-
extglobChars(chars) {
|
|
196
|
-
return {
|
|
197
|
-
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
198
|
-
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
199
|
-
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
200
|
-
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
201
|
-
'@': { type: 'at', open: '(?:', close: ')' }
|
|
202
|
-
};
|
|
203
|
-
},
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Create GLOB_CHARS
|
|
207
|
-
*/
|
|
208
|
-
|
|
209
|
-
globChars(win32) {
|
|
210
|
-
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
/***/ }),
|
|
216
|
-
|
|
217
|
-
/***/ 339:
|
|
218
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
219
|
-
|
|
220
|
-
"use strict";
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
const constants = __nccwpck_require__(717);
|
|
224
|
-
const utils = __nccwpck_require__(473);
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Constants
|
|
228
|
-
*/
|
|
229
|
-
|
|
230
|
-
const {
|
|
231
|
-
MAX_LENGTH,
|
|
232
|
-
POSIX_REGEX_SOURCE,
|
|
233
|
-
REGEX_NON_SPECIAL_CHARS,
|
|
234
|
-
REGEX_SPECIAL_CHARS_BACKREF,
|
|
235
|
-
REPLACEMENTS
|
|
236
|
-
} = constants;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Helpers
|
|
240
|
-
*/
|
|
241
|
-
|
|
242
|
-
const expandRange = (args, options) => {
|
|
243
|
-
if (typeof options.expandRange === 'function') {
|
|
244
|
-
return options.expandRange(...args, options);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
args.sort();
|
|
248
|
-
const value = `[${args.join('-')}]`;
|
|
249
|
-
|
|
250
|
-
try {
|
|
251
|
-
/* eslint-disable-next-line no-new */
|
|
252
|
-
new RegExp(value);
|
|
253
|
-
} catch (ex) {
|
|
254
|
-
return args.map(v => utils.escapeRegex(v)).join('..');
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return value;
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
/**
|
|
261
|
-
* Create the message for a syntax error
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
const syntaxError = (type, char) => {
|
|
265
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
/**
|
|
269
|
-
* Parse the given input string.
|
|
270
|
-
* @param {String} input
|
|
271
|
-
* @param {Object} options
|
|
272
|
-
* @return {Object}
|
|
273
|
-
*/
|
|
274
|
-
|
|
275
|
-
const parse = (input, options) => {
|
|
276
|
-
if (typeof input !== 'string') {
|
|
277
|
-
throw new TypeError('Expected a string');
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
input = REPLACEMENTS[input] || input;
|
|
281
|
-
|
|
282
|
-
const opts = { ...options };
|
|
283
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
284
|
-
|
|
285
|
-
let len = input.length;
|
|
286
|
-
if (len > max) {
|
|
287
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
291
|
-
const tokens = [bos];
|
|
292
|
-
|
|
293
|
-
const capture = opts.capture ? '' : '?:';
|
|
294
|
-
|
|
295
|
-
// create constants based on platform, for windows or posix
|
|
296
|
-
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
297
|
-
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
298
|
-
|
|
299
|
-
const {
|
|
300
|
-
DOT_LITERAL,
|
|
301
|
-
PLUS_LITERAL,
|
|
302
|
-
SLASH_LITERAL,
|
|
303
|
-
ONE_CHAR,
|
|
304
|
-
DOTS_SLASH,
|
|
305
|
-
NO_DOT,
|
|
306
|
-
NO_DOT_SLASH,
|
|
307
|
-
NO_DOTS_SLASH,
|
|
308
|
-
QMARK,
|
|
309
|
-
QMARK_NO_DOT,
|
|
310
|
-
STAR,
|
|
311
|
-
START_ANCHOR
|
|
312
|
-
} = PLATFORM_CHARS;
|
|
313
|
-
|
|
314
|
-
const globstar = opts => {
|
|
315
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const nodot = opts.dot ? '' : NO_DOT;
|
|
319
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
320
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
321
|
-
|
|
322
|
-
if (opts.capture) {
|
|
323
|
-
star = `(${star})`;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// minimatch options support
|
|
327
|
-
if (typeof opts.noext === 'boolean') {
|
|
328
|
-
opts.noextglob = opts.noext;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
const state = {
|
|
332
|
-
input,
|
|
333
|
-
index: -1,
|
|
334
|
-
start: 0,
|
|
335
|
-
dot: opts.dot === true,
|
|
336
|
-
consumed: '',
|
|
337
|
-
output: '',
|
|
338
|
-
prefix: '',
|
|
339
|
-
backtrack: false,
|
|
340
|
-
negated: false,
|
|
341
|
-
brackets: 0,
|
|
342
|
-
braces: 0,
|
|
343
|
-
parens: 0,
|
|
344
|
-
quotes: 0,
|
|
345
|
-
globstar: false,
|
|
346
|
-
tokens
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
input = utils.removePrefix(input, state);
|
|
350
|
-
len = input.length;
|
|
351
|
-
|
|
352
|
-
const extglobs = [];
|
|
353
|
-
const braces = [];
|
|
354
|
-
const stack = [];
|
|
355
|
-
let prev = bos;
|
|
356
|
-
let value;
|
|
357
|
-
|
|
358
|
-
/**
|
|
359
|
-
* Tokenizing helpers
|
|
360
|
-
*/
|
|
361
|
-
|
|
362
|
-
const eos = () => state.index === len - 1;
|
|
363
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
364
|
-
const advance = state.advance = () => input[++state.index] || '';
|
|
365
|
-
const remaining = () => input.slice(state.index + 1);
|
|
366
|
-
const consume = (value = '', num = 0) => {
|
|
367
|
-
state.consumed += value;
|
|
368
|
-
state.index += num;
|
|
369
|
-
};
|
|
370
|
-
|
|
371
|
-
const append = token => {
|
|
372
|
-
state.output += token.output != null ? token.output : token.value;
|
|
373
|
-
consume(token.value);
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
const negate = () => {
|
|
377
|
-
let count = 1;
|
|
378
|
-
|
|
379
|
-
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
380
|
-
advance();
|
|
381
|
-
state.start++;
|
|
382
|
-
count++;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
if (count % 2 === 0) {
|
|
386
|
-
return false;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
state.negated = true;
|
|
390
|
-
state.start++;
|
|
391
|
-
return true;
|
|
392
|
-
};
|
|
393
|
-
|
|
394
|
-
const increment = type => {
|
|
395
|
-
state[type]++;
|
|
396
|
-
stack.push(type);
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
const decrement = type => {
|
|
400
|
-
state[type]--;
|
|
401
|
-
stack.pop();
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
/**
|
|
405
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
406
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
407
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
408
|
-
* characters are plain text. This improves performance and simplifies
|
|
409
|
-
* lookbehinds.
|
|
410
|
-
*/
|
|
411
|
-
|
|
412
|
-
const push = tok => {
|
|
413
|
-
if (prev.type === 'globstar') {
|
|
414
|
-
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
415
|
-
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
416
|
-
|
|
417
|
-
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
418
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
419
|
-
prev.type = 'star';
|
|
420
|
-
prev.value = '*';
|
|
421
|
-
prev.output = star;
|
|
422
|
-
state.output += prev.output;
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
if (extglobs.length && tok.type !== 'paren') {
|
|
427
|
-
extglobs[extglobs.length - 1].inner += tok.value;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (tok.value || tok.output) append(tok);
|
|
431
|
-
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
432
|
-
prev.output = (prev.output || prev.value) + tok.value;
|
|
433
|
-
prev.value += tok.value;
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
tok.prev = prev;
|
|
438
|
-
tokens.push(tok);
|
|
439
|
-
prev = tok;
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const extglobOpen = (type, value) => {
|
|
443
|
-
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
444
|
-
|
|
445
|
-
token.prev = prev;
|
|
446
|
-
token.parens = state.parens;
|
|
447
|
-
token.output = state.output;
|
|
448
|
-
const output = (opts.capture ? '(' : '') + token.open;
|
|
449
|
-
|
|
450
|
-
increment('parens');
|
|
451
|
-
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
452
|
-
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
453
|
-
extglobs.push(token);
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
const extglobClose = token => {
|
|
457
|
-
let output = token.close + (opts.capture ? ')' : '');
|
|
458
|
-
let rest;
|
|
459
|
-
|
|
460
|
-
if (token.type === 'negate') {
|
|
461
|
-
let extglobStar = star;
|
|
462
|
-
|
|
463
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
464
|
-
extglobStar = globstar(opts);
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
468
|
-
output = token.close = `)$))${extglobStar}`;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
472
|
-
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
473
|
-
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
474
|
-
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
475
|
-
//
|
|
476
|
-
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
477
|
-
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
478
|
-
|
|
479
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
if (token.prev.type === 'bos') {
|
|
483
|
-
state.negatedExtglob = true;
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
push({ type: 'paren', extglob: true, value, output });
|
|
488
|
-
decrement('parens');
|
|
489
|
-
};
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Fast paths
|
|
493
|
-
*/
|
|
494
|
-
|
|
495
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
496
|
-
let backslashes = false;
|
|
497
|
-
|
|
498
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
499
|
-
if (first === '\\') {
|
|
500
|
-
backslashes = true;
|
|
501
|
-
return m;
|
|
502
|
-
}
|
|
503
|
-
|
|
504
|
-
if (first === '?') {
|
|
505
|
-
if (esc) {
|
|
506
|
-
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
507
|
-
}
|
|
508
|
-
if (index === 0) {
|
|
509
|
-
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
510
|
-
}
|
|
511
|
-
return QMARK.repeat(chars.length);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
if (first === '.') {
|
|
515
|
-
return DOT_LITERAL.repeat(chars.length);
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
if (first === '*') {
|
|
519
|
-
if (esc) {
|
|
520
|
-
return esc + first + (rest ? star : '');
|
|
521
|
-
}
|
|
522
|
-
return star;
|
|
523
|
-
}
|
|
524
|
-
return esc ? m : `\\${m}`;
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
if (backslashes === true) {
|
|
528
|
-
if (opts.unescape === true) {
|
|
529
|
-
output = output.replace(/\\/g, '');
|
|
530
|
-
} else {
|
|
531
|
-
output = output.replace(/\\+/g, m => {
|
|
532
|
-
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
533
|
-
});
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
|
|
537
|
-
if (output === input && opts.contains === true) {
|
|
538
|
-
state.output = input;
|
|
539
|
-
return state;
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
state.output = utils.wrapOutput(output, state, options);
|
|
543
|
-
return state;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
/**
|
|
547
|
-
* Tokenize input until we reach end-of-string
|
|
548
|
-
*/
|
|
549
|
-
|
|
550
|
-
while (!eos()) {
|
|
551
|
-
value = advance();
|
|
552
|
-
|
|
553
|
-
if (value === '\u0000') {
|
|
554
|
-
continue;
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Escaped characters
|
|
559
|
-
*/
|
|
560
|
-
|
|
561
|
-
if (value === '\\') {
|
|
562
|
-
const next = peek();
|
|
563
|
-
|
|
564
|
-
if (next === '/' && opts.bash !== true) {
|
|
565
|
-
continue;
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
if (next === '.' || next === ';') {
|
|
569
|
-
continue;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if (!next) {
|
|
573
|
-
value += '\\';
|
|
574
|
-
push({ type: 'text', value });
|
|
575
|
-
continue;
|
|
576
|
-
}
|
|
577
|
-
|
|
578
|
-
// collapse slashes to reduce potential for exploits
|
|
579
|
-
const match = /^\\+/.exec(remaining());
|
|
580
|
-
let slashes = 0;
|
|
581
|
-
|
|
582
|
-
if (match && match[0].length > 2) {
|
|
583
|
-
slashes = match[0].length;
|
|
584
|
-
state.index += slashes;
|
|
585
|
-
if (slashes % 2 !== 0) {
|
|
586
|
-
value += '\\';
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
if (opts.unescape === true) {
|
|
591
|
-
value = advance();
|
|
592
|
-
} else {
|
|
593
|
-
value += advance();
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
if (state.brackets === 0) {
|
|
597
|
-
push({ type: 'text', value });
|
|
598
|
-
continue;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
/**
|
|
603
|
-
* If we're inside a regex character class, continue
|
|
604
|
-
* until we reach the closing bracket.
|
|
605
|
-
*/
|
|
606
|
-
|
|
607
|
-
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
608
|
-
if (opts.posix !== false && value === ':') {
|
|
609
|
-
const inner = prev.value.slice(1);
|
|
610
|
-
if (inner.includes('[')) {
|
|
611
|
-
prev.posix = true;
|
|
612
|
-
|
|
613
|
-
if (inner.includes(':')) {
|
|
614
|
-
const idx = prev.value.lastIndexOf('[');
|
|
615
|
-
const pre = prev.value.slice(0, idx);
|
|
616
|
-
const rest = prev.value.slice(idx + 2);
|
|
617
|
-
const posix = POSIX_REGEX_SOURCE[rest];
|
|
618
|
-
if (posix) {
|
|
619
|
-
prev.value = pre + posix;
|
|
620
|
-
state.backtrack = true;
|
|
621
|
-
advance();
|
|
622
|
-
|
|
623
|
-
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
624
|
-
bos.output = ONE_CHAR;
|
|
625
|
-
}
|
|
626
|
-
continue;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
|
|
632
|
-
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
633
|
-
value = `\\${value}`;
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
637
|
-
value = `\\${value}`;
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
641
|
-
value = '^';
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
prev.value += value;
|
|
645
|
-
append({ value });
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* If we're inside a quoted string, continue
|
|
651
|
-
* until we reach the closing double quote.
|
|
652
|
-
*/
|
|
653
|
-
|
|
654
|
-
if (state.quotes === 1 && value !== '"') {
|
|
655
|
-
value = utils.escapeRegex(value);
|
|
656
|
-
prev.value += value;
|
|
657
|
-
append({ value });
|
|
658
|
-
continue;
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
/**
|
|
662
|
-
* Double quotes
|
|
663
|
-
*/
|
|
664
|
-
|
|
665
|
-
if (value === '"') {
|
|
666
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
667
|
-
if (opts.keepQuotes === true) {
|
|
668
|
-
push({ type: 'text', value });
|
|
669
|
-
}
|
|
670
|
-
continue;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
/**
|
|
674
|
-
* Parentheses
|
|
675
|
-
*/
|
|
676
|
-
|
|
677
|
-
if (value === '(') {
|
|
678
|
-
increment('parens');
|
|
679
|
-
push({ type: 'paren', value });
|
|
680
|
-
continue;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
if (value === ')') {
|
|
684
|
-
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
685
|
-
throw new SyntaxError(syntaxError('opening', '('));
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
689
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
690
|
-
extglobClose(extglobs.pop());
|
|
691
|
-
continue;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
695
|
-
decrement('parens');
|
|
696
|
-
continue;
|
|
697
|
-
}
|
|
698
|
-
|
|
699
|
-
/**
|
|
700
|
-
* Square brackets
|
|
701
|
-
*/
|
|
702
|
-
|
|
703
|
-
if (value === '[') {
|
|
704
|
-
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
705
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
706
|
-
throw new SyntaxError(syntaxError('closing', ']'));
|
|
707
|
-
}
|
|
708
|
-
|
|
709
|
-
value = `\\${value}`;
|
|
710
|
-
} else {
|
|
711
|
-
increment('brackets');
|
|
712
|
-
}
|
|
713
|
-
|
|
714
|
-
push({ type: 'bracket', value });
|
|
715
|
-
continue;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
if (value === ']') {
|
|
719
|
-
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
720
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
721
|
-
continue;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
if (state.brackets === 0) {
|
|
725
|
-
if (opts.strictBrackets === true) {
|
|
726
|
-
throw new SyntaxError(syntaxError('opening', '['));
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
730
|
-
continue;
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
decrement('brackets');
|
|
734
|
-
|
|
735
|
-
const prevValue = prev.value.slice(1);
|
|
736
|
-
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
737
|
-
value = `/${value}`;
|
|
738
|
-
}
|
|
739
|
-
|
|
740
|
-
prev.value += value;
|
|
741
|
-
append({ value });
|
|
742
|
-
|
|
743
|
-
// when literal brackets are explicitly disabled
|
|
744
|
-
// assume we should match with a regex character class
|
|
745
|
-
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
746
|
-
continue;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
750
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
751
|
-
|
|
752
|
-
// when literal brackets are explicitly enabled
|
|
753
|
-
// assume we should escape the brackets to match literal characters
|
|
754
|
-
if (opts.literalBrackets === true) {
|
|
755
|
-
state.output += escaped;
|
|
756
|
-
prev.value = escaped;
|
|
757
|
-
continue;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
// when the user specifies nothing, try to match both
|
|
761
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
762
|
-
state.output += prev.value;
|
|
763
|
-
continue;
|
|
764
|
-
}
|
|
765
|
-
|
|
766
|
-
/**
|
|
767
|
-
* Braces
|
|
768
|
-
*/
|
|
769
|
-
|
|
770
|
-
if (value === '{' && opts.nobrace !== true) {
|
|
771
|
-
increment('braces');
|
|
772
|
-
|
|
773
|
-
const open = {
|
|
774
|
-
type: 'brace',
|
|
775
|
-
value,
|
|
776
|
-
output: '(',
|
|
777
|
-
outputIndex: state.output.length,
|
|
778
|
-
tokensIndex: state.tokens.length
|
|
779
|
-
};
|
|
780
|
-
|
|
781
|
-
braces.push(open);
|
|
782
|
-
push(open);
|
|
783
|
-
continue;
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
if (value === '}') {
|
|
787
|
-
const brace = braces[braces.length - 1];
|
|
788
|
-
|
|
789
|
-
if (opts.nobrace === true || !brace) {
|
|
790
|
-
push({ type: 'text', value, output: value });
|
|
791
|
-
continue;
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
let output = ')';
|
|
795
|
-
|
|
796
|
-
if (brace.dots === true) {
|
|
797
|
-
const arr = tokens.slice();
|
|
798
|
-
const range = [];
|
|
799
|
-
|
|
800
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
801
|
-
tokens.pop();
|
|
802
|
-
if (arr[i].type === 'brace') {
|
|
803
|
-
break;
|
|
804
|
-
}
|
|
805
|
-
if (arr[i].type !== 'dots') {
|
|
806
|
-
range.unshift(arr[i].value);
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
|
|
810
|
-
output = expandRange(range, opts);
|
|
811
|
-
state.backtrack = true;
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
815
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
816
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
817
|
-
brace.value = brace.output = '\\{';
|
|
818
|
-
value = output = '\\}';
|
|
819
|
-
state.output = out;
|
|
820
|
-
for (const t of toks) {
|
|
821
|
-
state.output += (t.output || t.value);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
push({ type: 'brace', value, output });
|
|
826
|
-
decrement('braces');
|
|
827
|
-
braces.pop();
|
|
828
|
-
continue;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
/**
|
|
832
|
-
* Pipes
|
|
833
|
-
*/
|
|
834
|
-
|
|
835
|
-
if (value === '|') {
|
|
836
|
-
if (extglobs.length > 0) {
|
|
837
|
-
extglobs[extglobs.length - 1].conditions++;
|
|
838
|
-
}
|
|
839
|
-
push({ type: 'text', value });
|
|
840
|
-
continue;
|
|
841
|
-
}
|
|
842
|
-
|
|
843
|
-
/**
|
|
844
|
-
* Commas
|
|
845
|
-
*/
|
|
846
|
-
|
|
847
|
-
if (value === ',') {
|
|
848
|
-
let output = value;
|
|
849
|
-
|
|
850
|
-
const brace = braces[braces.length - 1];
|
|
851
|
-
if (brace && stack[stack.length - 1] === 'braces') {
|
|
852
|
-
brace.comma = true;
|
|
853
|
-
output = '|';
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
push({ type: 'comma', value, output });
|
|
857
|
-
continue;
|
|
858
|
-
}
|
|
859
|
-
|
|
860
|
-
/**
|
|
861
|
-
* Slashes
|
|
862
|
-
*/
|
|
863
|
-
|
|
864
|
-
if (value === '/') {
|
|
865
|
-
// if the beginning of the glob is "./", advance the start
|
|
866
|
-
// to the current index, and don't add the "./" characters
|
|
867
|
-
// to the state. This greatly simplifies lookbehinds when
|
|
868
|
-
// checking for BOS characters like "!" and "." (not "./")
|
|
869
|
-
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
870
|
-
state.start = state.index + 1;
|
|
871
|
-
state.consumed = '';
|
|
872
|
-
state.output = '';
|
|
873
|
-
tokens.pop();
|
|
874
|
-
prev = bos; // reset "prev" to the first token
|
|
875
|
-
continue;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
879
|
-
continue;
|
|
880
|
-
}
|
|
881
|
-
|
|
882
|
-
/**
|
|
883
|
-
* Dots
|
|
884
|
-
*/
|
|
885
|
-
|
|
886
|
-
if (value === '.') {
|
|
887
|
-
if (state.braces > 0 && prev.type === 'dot') {
|
|
888
|
-
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
889
|
-
const brace = braces[braces.length - 1];
|
|
890
|
-
prev.type = 'dots';
|
|
891
|
-
prev.output += value;
|
|
892
|
-
prev.value += value;
|
|
893
|
-
brace.dots = true;
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
898
|
-
push({ type: 'text', value, output: DOT_LITERAL });
|
|
899
|
-
continue;
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
903
|
-
continue;
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
/**
|
|
907
|
-
* Question marks
|
|
908
|
-
*/
|
|
909
|
-
|
|
910
|
-
if (value === '?') {
|
|
911
|
-
const isGroup = prev && prev.value === '(';
|
|
912
|
-
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
913
|
-
extglobOpen('qmark', value);
|
|
914
|
-
continue;
|
|
915
|
-
}
|
|
916
|
-
|
|
917
|
-
if (prev && prev.type === 'paren') {
|
|
918
|
-
const next = peek();
|
|
919
|
-
let output = value;
|
|
920
|
-
|
|
921
|
-
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
922
|
-
output = `\\${value}`;
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
push({ type: 'text', value, output });
|
|
926
|
-
continue;
|
|
927
|
-
}
|
|
928
|
-
|
|
929
|
-
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
930
|
-
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
931
|
-
continue;
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
push({ type: 'qmark', value, output: QMARK });
|
|
935
|
-
continue;
|
|
936
|
-
}
|
|
937
|
-
|
|
938
|
-
/**
|
|
939
|
-
* Exclamation
|
|
940
|
-
*/
|
|
941
|
-
|
|
942
|
-
if (value === '!') {
|
|
943
|
-
if (opts.noextglob !== true && peek() === '(') {
|
|
944
|
-
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
945
|
-
extglobOpen('negate', value);
|
|
946
|
-
continue;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
|
|
950
|
-
if (opts.nonegate !== true && state.index === 0) {
|
|
951
|
-
negate();
|
|
952
|
-
continue;
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
/**
|
|
957
|
-
* Plus
|
|
958
|
-
*/
|
|
959
|
-
|
|
960
|
-
if (value === '+') {
|
|
961
|
-
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
962
|
-
extglobOpen('plus', value);
|
|
963
|
-
continue;
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
967
|
-
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
968
|
-
continue;
|
|
969
|
-
}
|
|
970
|
-
|
|
971
|
-
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
972
|
-
push({ type: 'plus', value });
|
|
973
|
-
continue;
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
push({ type: 'plus', value: PLUS_LITERAL });
|
|
977
|
-
continue;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
/**
|
|
981
|
-
* Plain text
|
|
982
|
-
*/
|
|
983
|
-
|
|
984
|
-
if (value === '@') {
|
|
985
|
-
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
986
|
-
push({ type: 'at', extglob: true, value, output: '' });
|
|
987
|
-
continue;
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
push({ type: 'text', value });
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
/**
|
|
995
|
-
* Plain text
|
|
996
|
-
*/
|
|
997
|
-
|
|
998
|
-
if (value !== '*') {
|
|
999
|
-
if (value === '$' || value === '^') {
|
|
1000
|
-
value = `\\${value}`;
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1003
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1004
|
-
if (match) {
|
|
1005
|
-
value += match[0];
|
|
1006
|
-
state.index += match[0].length;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
push({ type: 'text', value });
|
|
1010
|
-
continue;
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
/**
|
|
1014
|
-
* Stars
|
|
1015
|
-
*/
|
|
1016
|
-
|
|
1017
|
-
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
1018
|
-
prev.type = 'star';
|
|
1019
|
-
prev.star = true;
|
|
1020
|
-
prev.value += value;
|
|
1021
|
-
prev.output = star;
|
|
1022
|
-
state.backtrack = true;
|
|
1023
|
-
state.globstar = true;
|
|
1024
|
-
consume(value);
|
|
1025
|
-
continue;
|
|
1026
|
-
}
|
|
1027
|
-
|
|
1028
|
-
let rest = remaining();
|
|
1029
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1030
|
-
extglobOpen('star', value);
|
|
1031
|
-
continue;
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
if (prev.type === 'star') {
|
|
1035
|
-
if (opts.noglobstar === true) {
|
|
1036
|
-
consume(value);
|
|
1037
|
-
continue;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
const prior = prev.prev;
|
|
1041
|
-
const before = prior.prev;
|
|
1042
|
-
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
1043
|
-
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
1044
|
-
|
|
1045
|
-
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
1046
|
-
push({ type: 'star', value, output: '' });
|
|
1047
|
-
continue;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
1051
|
-
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
1052
|
-
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
1053
|
-
push({ type: 'star', value, output: '' });
|
|
1054
|
-
continue;
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
// strip consecutive `/**/`
|
|
1058
|
-
while (rest.slice(0, 3) === '/**') {
|
|
1059
|
-
const after = input[state.index + 4];
|
|
1060
|
-
if (after && after !== '/') {
|
|
1061
|
-
break;
|
|
1062
|
-
}
|
|
1063
|
-
rest = rest.slice(3);
|
|
1064
|
-
consume('/**', 3);
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
if (prior.type === 'bos' && eos()) {
|
|
1068
|
-
prev.type = 'globstar';
|
|
1069
|
-
prev.value += value;
|
|
1070
|
-
prev.output = globstar(opts);
|
|
1071
|
-
state.output = prev.output;
|
|
1072
|
-
state.globstar = true;
|
|
1073
|
-
consume(value);
|
|
1074
|
-
continue;
|
|
1075
|
-
}
|
|
1076
|
-
|
|
1077
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
1078
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1079
|
-
prior.output = `(?:${prior.output}`;
|
|
1080
|
-
|
|
1081
|
-
prev.type = 'globstar';
|
|
1082
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
1083
|
-
prev.value += value;
|
|
1084
|
-
state.globstar = true;
|
|
1085
|
-
state.output += prior.output + prev.output;
|
|
1086
|
-
consume(value);
|
|
1087
|
-
continue;
|
|
1088
|
-
}
|
|
1089
|
-
|
|
1090
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
1091
|
-
const end = rest[1] !== void 0 ? '|$' : '';
|
|
1092
|
-
|
|
1093
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1094
|
-
prior.output = `(?:${prior.output}`;
|
|
1095
|
-
|
|
1096
|
-
prev.type = 'globstar';
|
|
1097
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1098
|
-
prev.value += value;
|
|
1099
|
-
|
|
1100
|
-
state.output += prior.output + prev.output;
|
|
1101
|
-
state.globstar = true;
|
|
1102
|
-
|
|
1103
|
-
consume(value + advance());
|
|
1104
|
-
|
|
1105
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
1106
|
-
continue;
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
if (prior.type === 'bos' && rest[0] === '/') {
|
|
1110
|
-
prev.type = 'globstar';
|
|
1111
|
-
prev.value += value;
|
|
1112
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1113
|
-
state.output = prev.output;
|
|
1114
|
-
state.globstar = true;
|
|
1115
|
-
consume(value + advance());
|
|
1116
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
1117
|
-
continue;
|
|
1118
|
-
}
|
|
1119
|
-
|
|
1120
|
-
// remove single star from output
|
|
1121
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
1122
|
-
|
|
1123
|
-
// reset previous token to globstar
|
|
1124
|
-
prev.type = 'globstar';
|
|
1125
|
-
prev.output = globstar(opts);
|
|
1126
|
-
prev.value += value;
|
|
1127
|
-
|
|
1128
|
-
// reset output with globstar
|
|
1129
|
-
state.output += prev.output;
|
|
1130
|
-
state.globstar = true;
|
|
1131
|
-
consume(value);
|
|
1132
|
-
continue;
|
|
1133
|
-
}
|
|
1134
|
-
|
|
1135
|
-
const token = { type: 'star', value, output: star };
|
|
1136
|
-
|
|
1137
|
-
if (opts.bash === true) {
|
|
1138
|
-
token.output = '.*?';
|
|
1139
|
-
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
1140
|
-
token.output = nodot + token.output;
|
|
1141
|
-
}
|
|
1142
|
-
push(token);
|
|
1143
|
-
continue;
|
|
1144
|
-
}
|
|
1145
|
-
|
|
1146
|
-
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
1147
|
-
token.output = value;
|
|
1148
|
-
push(token);
|
|
1149
|
-
continue;
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
1153
|
-
if (prev.type === 'dot') {
|
|
1154
|
-
state.output += NO_DOT_SLASH;
|
|
1155
|
-
prev.output += NO_DOT_SLASH;
|
|
1156
|
-
|
|
1157
|
-
} else if (opts.dot === true) {
|
|
1158
|
-
state.output += NO_DOTS_SLASH;
|
|
1159
|
-
prev.output += NO_DOTS_SLASH;
|
|
1160
|
-
|
|
1161
|
-
} else {
|
|
1162
|
-
state.output += nodot;
|
|
1163
|
-
prev.output += nodot;
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
if (peek() !== '*') {
|
|
1167
|
-
state.output += ONE_CHAR;
|
|
1168
|
-
prev.output += ONE_CHAR;
|
|
1169
|
-
}
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
push(token);
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
while (state.brackets > 0) {
|
|
1176
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
1177
|
-
state.output = utils.escapeLast(state.output, '[');
|
|
1178
|
-
decrement('brackets');
|
|
1179
|
-
}
|
|
1180
|
-
|
|
1181
|
-
while (state.parens > 0) {
|
|
1182
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
1183
|
-
state.output = utils.escapeLast(state.output, '(');
|
|
1184
|
-
decrement('parens');
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
while (state.braces > 0) {
|
|
1188
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
1189
|
-
state.output = utils.escapeLast(state.output, '{');
|
|
1190
|
-
decrement('braces');
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
1194
|
-
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
1195
|
-
}
|
|
1196
|
-
|
|
1197
|
-
// rebuild the output if we had to backtrack at any point
|
|
1198
|
-
if (state.backtrack === true) {
|
|
1199
|
-
state.output = '';
|
|
1200
|
-
|
|
1201
|
-
for (const token of state.tokens) {
|
|
1202
|
-
state.output += token.output != null ? token.output : token.value;
|
|
1203
|
-
|
|
1204
|
-
if (token.suffix) {
|
|
1205
|
-
state.output += token.suffix;
|
|
1206
|
-
}
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
return state;
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
|
-
/**
|
|
1214
|
-
* Fast paths for creating regular expressions for common glob patterns.
|
|
1215
|
-
* This can significantly speed up processing and has very little downside
|
|
1216
|
-
* impact when none of the fast paths match.
|
|
1217
|
-
*/
|
|
1218
|
-
|
|
1219
|
-
parse.fastpaths = (input, options) => {
|
|
1220
|
-
const opts = { ...options };
|
|
1221
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1222
|
-
const len = input.length;
|
|
1223
|
-
if (len > max) {
|
|
1224
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1225
|
-
}
|
|
1226
|
-
|
|
1227
|
-
input = REPLACEMENTS[input] || input;
|
|
1228
|
-
|
|
1229
|
-
// create constants based on platform, for windows or posix
|
|
1230
|
-
const {
|
|
1231
|
-
DOT_LITERAL,
|
|
1232
|
-
SLASH_LITERAL,
|
|
1233
|
-
ONE_CHAR,
|
|
1234
|
-
DOTS_SLASH,
|
|
1235
|
-
NO_DOT,
|
|
1236
|
-
NO_DOTS,
|
|
1237
|
-
NO_DOTS_SLASH,
|
|
1238
|
-
STAR,
|
|
1239
|
-
START_ANCHOR
|
|
1240
|
-
} = constants.globChars(opts.windows);
|
|
1241
|
-
|
|
1242
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1243
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1244
|
-
const capture = opts.capture ? '' : '?:';
|
|
1245
|
-
const state = { negated: false, prefix: '' };
|
|
1246
|
-
let star = opts.bash === true ? '.*?' : STAR;
|
|
1247
|
-
|
|
1248
|
-
if (opts.capture) {
|
|
1249
|
-
star = `(${star})`;
|
|
1250
|
-
}
|
|
1251
|
-
|
|
1252
|
-
const globstar = opts => {
|
|
1253
|
-
if (opts.noglobstar === true) return star;
|
|
1254
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1255
|
-
};
|
|
1256
|
-
|
|
1257
|
-
const create = str => {
|
|
1258
|
-
switch (str) {
|
|
1259
|
-
case '*':
|
|
1260
|
-
return `${nodot}${ONE_CHAR}${star}`;
|
|
1261
|
-
|
|
1262
|
-
case '.*':
|
|
1263
|
-
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1264
|
-
|
|
1265
|
-
case '*.*':
|
|
1266
|
-
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1267
|
-
|
|
1268
|
-
case '*/*':
|
|
1269
|
-
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1270
|
-
|
|
1271
|
-
case '**':
|
|
1272
|
-
return nodot + globstar(opts);
|
|
1273
|
-
|
|
1274
|
-
case '**/*':
|
|
1275
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1276
|
-
|
|
1277
|
-
case '**/*.*':
|
|
1278
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1279
|
-
|
|
1280
|
-
case '**/.*':
|
|
1281
|
-
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1282
|
-
|
|
1283
|
-
default: {
|
|
1284
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1285
|
-
if (!match) return;
|
|
1286
|
-
|
|
1287
|
-
const source = create(match[1]);
|
|
1288
|
-
if (!source) return;
|
|
1289
|
-
|
|
1290
|
-
return source + DOT_LITERAL + match[2];
|
|
1291
|
-
}
|
|
1292
|
-
}
|
|
1293
|
-
};
|
|
1294
|
-
|
|
1295
|
-
const output = utils.removePrefix(input, state);
|
|
1296
|
-
let source = create(output);
|
|
1297
|
-
|
|
1298
|
-
if (source && opts.strictSlashes !== true) {
|
|
1299
|
-
source += `${SLASH_LITERAL}?`;
|
|
1300
|
-
}
|
|
1301
|
-
|
|
1302
|
-
return source;
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
|
-
module.exports = parse;
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
/***/ }),
|
|
1309
|
-
|
|
1310
|
-
/***/ 582:
|
|
1311
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1312
|
-
|
|
1313
|
-
"use strict";
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
const scan = __nccwpck_require__(279);
|
|
1317
|
-
const parse = __nccwpck_require__(339);
|
|
1318
|
-
const utils = __nccwpck_require__(473);
|
|
1319
|
-
const constants = __nccwpck_require__(717);
|
|
1320
|
-
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
1321
|
-
|
|
1322
|
-
/**
|
|
1323
|
-
* Creates a matcher function from one or more glob patterns. The
|
|
1324
|
-
* returned function takes a string to match as its first argument,
|
|
1325
|
-
* and returns true if the string is a match. The returned matcher
|
|
1326
|
-
* function also takes a boolean as the second argument that, when true,
|
|
1327
|
-
* returns an object with additional information.
|
|
1328
|
-
*
|
|
1329
|
-
* ```js
|
|
1330
|
-
* const picomatch = require('picomatch');
|
|
1331
|
-
* // picomatch(glob[, options]);
|
|
1332
|
-
*
|
|
1333
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
1334
|
-
* console.log(isMatch('a.a')); //=> false
|
|
1335
|
-
* console.log(isMatch('a.b')); //=> true
|
|
1336
|
-
* ```
|
|
1337
|
-
* @name picomatch
|
|
1338
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
1339
|
-
* @param {Object=} `options`
|
|
1340
|
-
* @return {Function=} Returns a matcher function.
|
|
1341
|
-
* @api public
|
|
1342
|
-
*/
|
|
1343
|
-
|
|
1344
|
-
const picomatch = (glob, options, returnState = false) => {
|
|
1345
|
-
if (Array.isArray(glob)) {
|
|
1346
|
-
const fns = glob.map(input => picomatch(input, options, returnState));
|
|
1347
|
-
const arrayMatcher = str => {
|
|
1348
|
-
for (const isMatch of fns) {
|
|
1349
|
-
const state = isMatch(str);
|
|
1350
|
-
if (state) return state;
|
|
1351
|
-
}
|
|
1352
|
-
return false;
|
|
1353
|
-
};
|
|
1354
|
-
return arrayMatcher;
|
|
1355
|
-
}
|
|
1356
|
-
|
|
1357
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1358
|
-
|
|
1359
|
-
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
1360
|
-
throw new TypeError('Expected pattern to be a non-empty string');
|
|
1361
|
-
}
|
|
1362
|
-
|
|
1363
|
-
const opts = options || {};
|
|
1364
|
-
const posix = opts.windows;
|
|
1365
|
-
const regex = isState
|
|
1366
|
-
? picomatch.compileRe(glob, options)
|
|
1367
|
-
: picomatch.makeRe(glob, options, false, true);
|
|
1368
|
-
|
|
1369
|
-
const state = regex.state;
|
|
1370
|
-
delete regex.state;
|
|
1371
|
-
|
|
1372
|
-
let isIgnored = () => false;
|
|
1373
|
-
if (opts.ignore) {
|
|
1374
|
-
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
1375
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1376
|
-
}
|
|
1377
|
-
|
|
1378
|
-
const matcher = (input, returnObject = false) => {
|
|
1379
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
1380
|
-
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
1381
|
-
|
|
1382
|
-
if (typeof opts.onResult === 'function') {
|
|
1383
|
-
opts.onResult(result);
|
|
1384
|
-
}
|
|
1385
|
-
|
|
1386
|
-
if (isMatch === false) {
|
|
1387
|
-
result.isMatch = false;
|
|
1388
|
-
return returnObject ? result : false;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
if (isIgnored(input)) {
|
|
1392
|
-
if (typeof opts.onIgnore === 'function') {
|
|
1393
|
-
opts.onIgnore(result);
|
|
1394
|
-
}
|
|
1395
|
-
result.isMatch = false;
|
|
1396
|
-
return returnObject ? result : false;
|
|
1397
|
-
}
|
|
1398
|
-
|
|
1399
|
-
if (typeof opts.onMatch === 'function') {
|
|
1400
|
-
opts.onMatch(result);
|
|
1401
|
-
}
|
|
1402
|
-
return returnObject ? result : true;
|
|
1403
|
-
};
|
|
1404
|
-
|
|
1405
|
-
if (returnState) {
|
|
1406
|
-
matcher.state = state;
|
|
1407
|
-
}
|
|
1408
|
-
|
|
1409
|
-
return matcher;
|
|
1410
|
-
};
|
|
1411
|
-
|
|
1412
|
-
/**
|
|
1413
|
-
* Test `input` with the given `regex`. This is used by the main
|
|
1414
|
-
* `picomatch()` function to test the input string.
|
|
1415
|
-
*
|
|
1416
|
-
* ```js
|
|
1417
|
-
* const picomatch = require('picomatch');
|
|
1418
|
-
* // picomatch.test(input, regex[, options]);
|
|
1419
|
-
*
|
|
1420
|
-
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
1421
|
-
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
1422
|
-
* ```
|
|
1423
|
-
* @param {String} `input` String to test.
|
|
1424
|
-
* @param {RegExp} `regex`
|
|
1425
|
-
* @return {Object} Returns an object with matching info.
|
|
1426
|
-
* @api public
|
|
1427
|
-
*/
|
|
1428
|
-
|
|
1429
|
-
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
1430
|
-
if (typeof input !== 'string') {
|
|
1431
|
-
throw new TypeError('Expected input to be a string');
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
if (input === '') {
|
|
1435
|
-
return { isMatch: false, output: '' };
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
|
-
const opts = options || {};
|
|
1439
|
-
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
1440
|
-
let match = input === glob;
|
|
1441
|
-
let output = (match && format) ? format(input) : input;
|
|
1442
|
-
|
|
1443
|
-
if (match === false) {
|
|
1444
|
-
output = format ? format(input) : input;
|
|
1445
|
-
match = output === glob;
|
|
1446
|
-
}
|
|
1447
|
-
|
|
1448
|
-
if (match === false || opts.capture === true) {
|
|
1449
|
-
if (opts.matchBase === true || opts.basename === true) {
|
|
1450
|
-
match = picomatch.matchBase(input, regex, options, posix);
|
|
1451
|
-
} else {
|
|
1452
|
-
match = regex.exec(output);
|
|
1453
|
-
}
|
|
1454
|
-
}
|
|
1455
|
-
|
|
1456
|
-
return { isMatch: Boolean(match), match, output };
|
|
1457
|
-
};
|
|
1458
|
-
|
|
1459
|
-
/**
|
|
1460
|
-
* Match the basename of a filepath.
|
|
1461
|
-
*
|
|
1462
|
-
* ```js
|
|
1463
|
-
* const picomatch = require('picomatch');
|
|
1464
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
1465
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
1466
|
-
* ```
|
|
1467
|
-
* @param {String} `input` String to test.
|
|
1468
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
1469
|
-
* @return {Boolean}
|
|
1470
|
-
* @api public
|
|
1471
|
-
*/
|
|
1472
|
-
|
|
1473
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
1474
|
-
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
1475
|
-
return regex.test(utils.basename(input));
|
|
1476
|
-
};
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
1480
|
-
*
|
|
1481
|
-
* ```js
|
|
1482
|
-
* const picomatch = require('picomatch');
|
|
1483
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
1484
|
-
*
|
|
1485
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
1486
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
1487
|
-
* ```
|
|
1488
|
-
* @param {String|Array} str The string to test.
|
|
1489
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
1490
|
-
* @param {Object} [options] See available [options](#options).
|
|
1491
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
1492
|
-
* @api public
|
|
1493
|
-
*/
|
|
1494
|
-
|
|
1495
|
-
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1496
|
-
|
|
1497
|
-
/**
|
|
1498
|
-
* Parse a glob pattern to create the source string for a regular
|
|
1499
|
-
* expression.
|
|
1500
|
-
*
|
|
1501
|
-
* ```js
|
|
1502
|
-
* const picomatch = require('picomatch');
|
|
1503
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
1504
|
-
* ```
|
|
1505
|
-
* @param {String} `pattern`
|
|
1506
|
-
* @param {Object} `options`
|
|
1507
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
1508
|
-
* @api public
|
|
1509
|
-
*/
|
|
1510
|
-
|
|
1511
|
-
picomatch.parse = (pattern, options) => {
|
|
1512
|
-
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
1513
|
-
return parse(pattern, { ...options, fastpaths: false });
|
|
1514
|
-
};
|
|
1515
|
-
|
|
1516
|
-
/**
|
|
1517
|
-
* Scan a glob pattern to separate the pattern into segments.
|
|
1518
|
-
*
|
|
1519
|
-
* ```js
|
|
1520
|
-
* const picomatch = require('picomatch');
|
|
1521
|
-
* // picomatch.scan(input[, options]);
|
|
1522
|
-
*
|
|
1523
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
1524
|
-
* console.log(result);
|
|
1525
|
-
* { prefix: '!./',
|
|
1526
|
-
* input: '!./foo/*.js',
|
|
1527
|
-
* start: 3,
|
|
1528
|
-
* base: 'foo',
|
|
1529
|
-
* glob: '*.js',
|
|
1530
|
-
* isBrace: false,
|
|
1531
|
-
* isBracket: false,
|
|
1532
|
-
* isGlob: true,
|
|
1533
|
-
* isExtglob: false,
|
|
1534
|
-
* isGlobstar: false,
|
|
1535
|
-
* negated: true }
|
|
1536
|
-
* ```
|
|
1537
|
-
* @param {String} `input` Glob pattern to scan.
|
|
1538
|
-
* @param {Object} `options`
|
|
1539
|
-
* @return {Object} Returns an object with
|
|
1540
|
-
* @api public
|
|
1541
|
-
*/
|
|
1542
|
-
|
|
1543
|
-
picomatch.scan = (input, options) => scan(input, options);
|
|
1544
|
-
|
|
1545
|
-
/**
|
|
1546
|
-
* Compile a regular expression from the `state` object returned by the
|
|
1547
|
-
* [parse()](#parse) method.
|
|
1548
|
-
*
|
|
1549
|
-
* @param {Object} `state`
|
|
1550
|
-
* @param {Object} `options`
|
|
1551
|
-
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
1552
|
-
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
1553
|
-
* @return {RegExp}
|
|
1554
|
-
* @api public
|
|
1555
|
-
*/
|
|
1556
|
-
|
|
1557
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1558
|
-
if (returnOutput === true) {
|
|
1559
|
-
return state.output;
|
|
1560
|
-
}
|
|
1561
|
-
|
|
1562
|
-
const opts = options || {};
|
|
1563
|
-
const prepend = opts.contains ? '' : '^';
|
|
1564
|
-
const append = opts.contains ? '' : '$';
|
|
1565
|
-
|
|
1566
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
1567
|
-
if (state && state.negated === true) {
|
|
1568
|
-
source = `^(?!${source}).*$`;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
const regex = picomatch.toRegex(source, options);
|
|
1572
|
-
if (returnState === true) {
|
|
1573
|
-
regex.state = state;
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
return regex;
|
|
1577
|
-
};
|
|
1578
|
-
|
|
1579
|
-
/**
|
|
1580
|
-
* Create a regular expression from a parsed glob pattern.
|
|
1581
|
-
*
|
|
1582
|
-
* ```js
|
|
1583
|
-
* const picomatch = require('picomatch');
|
|
1584
|
-
* const state = picomatch.parse('*.js');
|
|
1585
|
-
* // picomatch.compileRe(state[, options]);
|
|
1586
|
-
*
|
|
1587
|
-
* console.log(picomatch.compileRe(state));
|
|
1588
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1589
|
-
* ```
|
|
1590
|
-
* @param {String} `state` The object returned from the `.parse` method.
|
|
1591
|
-
* @param {Object} `options`
|
|
1592
|
-
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
1593
|
-
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
1594
|
-
* @return {RegExp} Returns a regex created from the given pattern.
|
|
1595
|
-
* @api public
|
|
1596
|
-
*/
|
|
1597
|
-
|
|
1598
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1599
|
-
if (!input || typeof input !== 'string') {
|
|
1600
|
-
throw new TypeError('Expected a non-empty string');
|
|
1601
|
-
}
|
|
1602
|
-
|
|
1603
|
-
let parsed = { negated: false, fastpaths: true };
|
|
1604
|
-
|
|
1605
|
-
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
1606
|
-
parsed.output = parse.fastpaths(input, options);
|
|
1607
|
-
}
|
|
1608
|
-
|
|
1609
|
-
if (!parsed.output) {
|
|
1610
|
-
parsed = parse(input, options);
|
|
1611
|
-
}
|
|
1612
|
-
|
|
1613
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1614
|
-
};
|
|
1615
|
-
|
|
1616
|
-
/**
|
|
1617
|
-
* Create a regular expression from the given regex source string.
|
|
1618
|
-
*
|
|
1619
|
-
* ```js
|
|
1620
|
-
* const picomatch = require('picomatch');
|
|
1621
|
-
* // picomatch.toRegex(source[, options]);
|
|
1622
|
-
*
|
|
1623
|
-
* const { output } = picomatch.parse('*.js');
|
|
1624
|
-
* console.log(picomatch.toRegex(output));
|
|
1625
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1626
|
-
* ```
|
|
1627
|
-
* @param {String} `source` Regular expression source string.
|
|
1628
|
-
* @param {Object} `options`
|
|
1629
|
-
* @return {RegExp}
|
|
1630
|
-
* @api public
|
|
1631
|
-
*/
|
|
1632
|
-
|
|
1633
|
-
picomatch.toRegex = (source, options) => {
|
|
1634
|
-
try {
|
|
1635
|
-
const opts = options || {};
|
|
1636
|
-
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
1637
|
-
} catch (err) {
|
|
1638
|
-
if (options && options.debug === true) throw err;
|
|
1639
|
-
return /$^/;
|
|
1640
|
-
}
|
|
1641
|
-
};
|
|
1642
|
-
|
|
1643
|
-
/**
|
|
1644
|
-
* Picomatch constants.
|
|
1645
|
-
* @return {Object}
|
|
1646
|
-
*/
|
|
1647
|
-
|
|
1648
|
-
picomatch.constants = constants;
|
|
1649
|
-
|
|
1650
|
-
/**
|
|
1651
|
-
* Expose "picomatch"
|
|
1652
|
-
*/
|
|
1653
|
-
|
|
1654
|
-
module.exports = picomatch;
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
/***/ }),
|
|
1658
|
-
|
|
1659
|
-
/***/ 279:
|
|
1660
|
-
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
|
|
1661
|
-
|
|
1662
|
-
"use strict";
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
const utils = __nccwpck_require__(473);
|
|
1666
|
-
const {
|
|
1667
|
-
CHAR_ASTERISK, /* * */
|
|
1668
|
-
CHAR_AT, /* @ */
|
|
1669
|
-
CHAR_BACKWARD_SLASH, /* \ */
|
|
1670
|
-
CHAR_COMMA, /* , */
|
|
1671
|
-
CHAR_DOT, /* . */
|
|
1672
|
-
CHAR_EXCLAMATION_MARK, /* ! */
|
|
1673
|
-
CHAR_FORWARD_SLASH, /* / */
|
|
1674
|
-
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
1675
|
-
CHAR_LEFT_PARENTHESES, /* ( */
|
|
1676
|
-
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
1677
|
-
CHAR_PLUS, /* + */
|
|
1678
|
-
CHAR_QUESTION_MARK, /* ? */
|
|
1679
|
-
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
1680
|
-
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
1681
|
-
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
1682
|
-
} = __nccwpck_require__(717);
|
|
1683
|
-
|
|
1684
|
-
const isPathSeparator = code => {
|
|
1685
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1686
|
-
};
|
|
1687
|
-
|
|
1688
|
-
const depth = token => {
|
|
1689
|
-
if (token.isPrefix !== true) {
|
|
1690
|
-
token.depth = token.isGlobstar ? Infinity : 1;
|
|
1691
|
-
}
|
|
1692
|
-
};
|
|
1693
|
-
|
|
1694
|
-
/**
|
|
1695
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
1696
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
1697
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
1698
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
1699
|
-
*
|
|
1700
|
-
* ```js
|
|
1701
|
-
* const pm = require('picomatch');
|
|
1702
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
1703
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
1704
|
-
* ```
|
|
1705
|
-
* @param {String} `str`
|
|
1706
|
-
* @param {Object} `options`
|
|
1707
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
1708
|
-
* @api public
|
|
1709
|
-
*/
|
|
1710
|
-
|
|
1711
|
-
const scan = (input, options) => {
|
|
1712
|
-
const opts = options || {};
|
|
1713
|
-
|
|
1714
|
-
const length = input.length - 1;
|
|
1715
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1716
|
-
const slashes = [];
|
|
1717
|
-
const tokens = [];
|
|
1718
|
-
const parts = [];
|
|
1719
|
-
|
|
1720
|
-
let str = input;
|
|
1721
|
-
let index = -1;
|
|
1722
|
-
let start = 0;
|
|
1723
|
-
let lastIndex = 0;
|
|
1724
|
-
let isBrace = false;
|
|
1725
|
-
let isBracket = false;
|
|
1726
|
-
let isGlob = false;
|
|
1727
|
-
let isExtglob = false;
|
|
1728
|
-
let isGlobstar = false;
|
|
1729
|
-
let braceEscaped = false;
|
|
1730
|
-
let backslashes = false;
|
|
1731
|
-
let negated = false;
|
|
1732
|
-
let negatedExtglob = false;
|
|
1733
|
-
let finished = false;
|
|
1734
|
-
let braces = 0;
|
|
1735
|
-
let prev;
|
|
1736
|
-
let code;
|
|
1737
|
-
let token = { value: '', depth: 0, isGlob: false };
|
|
1738
|
-
|
|
1739
|
-
const eos = () => index >= length;
|
|
1740
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
1741
|
-
const advance = () => {
|
|
1742
|
-
prev = code;
|
|
1743
|
-
return str.charCodeAt(++index);
|
|
1744
|
-
};
|
|
1745
|
-
|
|
1746
|
-
while (index < length) {
|
|
1747
|
-
code = advance();
|
|
1748
|
-
let next;
|
|
1749
|
-
|
|
1750
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1751
|
-
backslashes = token.backslashes = true;
|
|
1752
|
-
code = advance();
|
|
1753
|
-
|
|
1754
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1755
|
-
braceEscaped = true;
|
|
1756
|
-
}
|
|
1757
|
-
continue;
|
|
1758
|
-
}
|
|
1759
|
-
|
|
1760
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1761
|
-
braces++;
|
|
1762
|
-
|
|
1763
|
-
while (eos() !== true && (code = advance())) {
|
|
1764
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1765
|
-
backslashes = token.backslashes = true;
|
|
1766
|
-
advance();
|
|
1767
|
-
continue;
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1771
|
-
braces++;
|
|
1772
|
-
continue;
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1776
|
-
isBrace = token.isBrace = true;
|
|
1777
|
-
isGlob = token.isGlob = true;
|
|
1778
|
-
finished = true;
|
|
1779
|
-
|
|
1780
|
-
if (scanToEnd === true) {
|
|
1781
|
-
continue;
|
|
1782
|
-
}
|
|
1783
|
-
|
|
1784
|
-
break;
|
|
1785
|
-
}
|
|
1786
|
-
|
|
1787
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1788
|
-
isBrace = token.isBrace = true;
|
|
1789
|
-
isGlob = token.isGlob = true;
|
|
1790
|
-
finished = true;
|
|
1791
|
-
|
|
1792
|
-
if (scanToEnd === true) {
|
|
1793
|
-
continue;
|
|
1794
|
-
}
|
|
1795
|
-
|
|
1796
|
-
break;
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1800
|
-
braces--;
|
|
1801
|
-
|
|
1802
|
-
if (braces === 0) {
|
|
1803
|
-
braceEscaped = false;
|
|
1804
|
-
isBrace = token.isBrace = true;
|
|
1805
|
-
finished = true;
|
|
1806
|
-
break;
|
|
1807
|
-
}
|
|
1808
|
-
}
|
|
1809
|
-
}
|
|
1810
|
-
|
|
1811
|
-
if (scanToEnd === true) {
|
|
1812
|
-
continue;
|
|
1813
|
-
}
|
|
1814
|
-
|
|
1815
|
-
break;
|
|
1816
|
-
}
|
|
1817
|
-
|
|
1818
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
1819
|
-
slashes.push(index);
|
|
1820
|
-
tokens.push(token);
|
|
1821
|
-
token = { value: '', depth: 0, isGlob: false };
|
|
1822
|
-
|
|
1823
|
-
if (finished === true) continue;
|
|
1824
|
-
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
1825
|
-
start += 2;
|
|
1826
|
-
continue;
|
|
1827
|
-
}
|
|
1828
|
-
|
|
1829
|
-
lastIndex = index + 1;
|
|
1830
|
-
continue;
|
|
1831
|
-
}
|
|
1832
|
-
|
|
1833
|
-
if (opts.noext !== true) {
|
|
1834
|
-
const isExtglobChar = code === CHAR_PLUS
|
|
1835
|
-
|| code === CHAR_AT
|
|
1836
|
-
|| code === CHAR_ASTERISK
|
|
1837
|
-
|| code === CHAR_QUESTION_MARK
|
|
1838
|
-
|| code === CHAR_EXCLAMATION_MARK;
|
|
1839
|
-
|
|
1840
|
-
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1841
|
-
isGlob = token.isGlob = true;
|
|
1842
|
-
isExtglob = token.isExtglob = true;
|
|
1843
|
-
finished = true;
|
|
1844
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1845
|
-
negatedExtglob = true;
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
if (scanToEnd === true) {
|
|
1849
|
-
while (eos() !== true && (code = advance())) {
|
|
1850
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
1851
|
-
backslashes = token.backslashes = true;
|
|
1852
|
-
code = advance();
|
|
1853
|
-
continue;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1857
|
-
isGlob = token.isGlob = true;
|
|
1858
|
-
finished = true;
|
|
1859
|
-
break;
|
|
1860
|
-
}
|
|
1861
|
-
}
|
|
1862
|
-
continue;
|
|
1863
|
-
}
|
|
1864
|
-
break;
|
|
1865
|
-
}
|
|
1866
|
-
}
|
|
1867
|
-
|
|
1868
|
-
if (code === CHAR_ASTERISK) {
|
|
1869
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1870
|
-
isGlob = token.isGlob = true;
|
|
1871
|
-
finished = true;
|
|
1872
|
-
|
|
1873
|
-
if (scanToEnd === true) {
|
|
1874
|
-
continue;
|
|
1875
|
-
}
|
|
1876
|
-
break;
|
|
1877
|
-
}
|
|
1878
|
-
|
|
1879
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
1880
|
-
isGlob = token.isGlob = true;
|
|
1881
|
-
finished = true;
|
|
1882
|
-
|
|
1883
|
-
if (scanToEnd === true) {
|
|
1884
|
-
continue;
|
|
1885
|
-
}
|
|
1886
|
-
break;
|
|
1887
|
-
}
|
|
1888
|
-
|
|
1889
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1890
|
-
while (eos() !== true && (next = advance())) {
|
|
1891
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
1892
|
-
backslashes = token.backslashes = true;
|
|
1893
|
-
advance();
|
|
1894
|
-
continue;
|
|
1895
|
-
}
|
|
1896
|
-
|
|
1897
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1898
|
-
isBracket = token.isBracket = true;
|
|
1899
|
-
isGlob = token.isGlob = true;
|
|
1900
|
-
finished = true;
|
|
1901
|
-
break;
|
|
1902
|
-
}
|
|
1903
|
-
}
|
|
1904
|
-
|
|
1905
|
-
if (scanToEnd === true) {
|
|
1906
|
-
continue;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
break;
|
|
1910
|
-
}
|
|
1911
|
-
|
|
1912
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1913
|
-
negated = token.negated = true;
|
|
1914
|
-
start++;
|
|
1915
|
-
continue;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1919
|
-
isGlob = token.isGlob = true;
|
|
1920
|
-
|
|
1921
|
-
if (scanToEnd === true) {
|
|
1922
|
-
while (eos() !== true && (code = advance())) {
|
|
1923
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1924
|
-
backslashes = token.backslashes = true;
|
|
1925
|
-
code = advance();
|
|
1926
|
-
continue;
|
|
1927
|
-
}
|
|
1928
|
-
|
|
1929
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1930
|
-
finished = true;
|
|
1931
|
-
break;
|
|
1932
|
-
}
|
|
1933
|
-
}
|
|
1934
|
-
continue;
|
|
1935
|
-
}
|
|
1936
|
-
break;
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
if (isGlob === true) {
|
|
1940
|
-
finished = true;
|
|
1941
|
-
|
|
1942
|
-
if (scanToEnd === true) {
|
|
1943
|
-
continue;
|
|
1944
|
-
}
|
|
1945
|
-
|
|
1946
|
-
break;
|
|
1947
|
-
}
|
|
1948
|
-
}
|
|
1949
|
-
|
|
1950
|
-
if (opts.noext === true) {
|
|
1951
|
-
isExtglob = false;
|
|
1952
|
-
isGlob = false;
|
|
1953
|
-
}
|
|
1954
|
-
|
|
1955
|
-
let base = str;
|
|
1956
|
-
let prefix = '';
|
|
1957
|
-
let glob = '';
|
|
1958
|
-
|
|
1959
|
-
if (start > 0) {
|
|
1960
|
-
prefix = str.slice(0, start);
|
|
1961
|
-
str = str.slice(start);
|
|
1962
|
-
lastIndex -= start;
|
|
1963
|
-
}
|
|
1964
|
-
|
|
1965
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
1966
|
-
base = str.slice(0, lastIndex);
|
|
1967
|
-
glob = str.slice(lastIndex);
|
|
1968
|
-
} else if (isGlob === true) {
|
|
1969
|
-
base = '';
|
|
1970
|
-
glob = str;
|
|
1971
|
-
} else {
|
|
1972
|
-
base = str;
|
|
1973
|
-
}
|
|
1974
|
-
|
|
1975
|
-
if (base && base !== '' && base !== '/' && base !== str) {
|
|
1976
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
1977
|
-
base = base.slice(0, -1);
|
|
1978
|
-
}
|
|
1979
|
-
}
|
|
1980
|
-
|
|
1981
|
-
if (opts.unescape === true) {
|
|
1982
|
-
if (glob) glob = utils.removeBackslashes(glob);
|
|
1983
|
-
|
|
1984
|
-
if (base && backslashes === true) {
|
|
1985
|
-
base = utils.removeBackslashes(base);
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
const state = {
|
|
1990
|
-
prefix,
|
|
1991
|
-
input,
|
|
1992
|
-
start,
|
|
1993
|
-
base,
|
|
1994
|
-
glob,
|
|
1995
|
-
isBrace,
|
|
1996
|
-
isBracket,
|
|
1997
|
-
isGlob,
|
|
1998
|
-
isExtglob,
|
|
1999
|
-
isGlobstar,
|
|
2000
|
-
negated,
|
|
2001
|
-
negatedExtglob
|
|
2002
|
-
};
|
|
2003
|
-
|
|
2004
|
-
if (opts.tokens === true) {
|
|
2005
|
-
state.maxDepth = 0;
|
|
2006
|
-
if (!isPathSeparator(code)) {
|
|
2007
|
-
tokens.push(token);
|
|
2008
|
-
}
|
|
2009
|
-
state.tokens = tokens;
|
|
2010
|
-
}
|
|
2011
|
-
|
|
2012
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
2013
|
-
let prevIndex;
|
|
2014
|
-
|
|
2015
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
2016
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
2017
|
-
const i = slashes[idx];
|
|
2018
|
-
const value = input.slice(n, i);
|
|
2019
|
-
if (opts.tokens) {
|
|
2020
|
-
if (idx === 0 && start !== 0) {
|
|
2021
|
-
tokens[idx].isPrefix = true;
|
|
2022
|
-
tokens[idx].value = prefix;
|
|
2023
|
-
} else {
|
|
2024
|
-
tokens[idx].value = value;
|
|
2025
|
-
}
|
|
2026
|
-
depth(tokens[idx]);
|
|
2027
|
-
state.maxDepth += tokens[idx].depth;
|
|
2028
|
-
}
|
|
2029
|
-
if (idx !== 0 || value !== '') {
|
|
2030
|
-
parts.push(value);
|
|
2031
|
-
}
|
|
2032
|
-
prevIndex = i;
|
|
2033
|
-
}
|
|
2034
|
-
|
|
2035
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
2036
|
-
const value = input.slice(prevIndex + 1);
|
|
2037
|
-
parts.push(value);
|
|
2038
|
-
|
|
2039
|
-
if (opts.tokens) {
|
|
2040
|
-
tokens[tokens.length - 1].value = value;
|
|
2041
|
-
depth(tokens[tokens.length - 1]);
|
|
2042
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
2043
|
-
}
|
|
2044
|
-
}
|
|
2045
|
-
|
|
2046
|
-
state.slashes = slashes;
|
|
2047
|
-
state.parts = parts;
|
|
2048
|
-
}
|
|
2049
|
-
|
|
2050
|
-
return state;
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
module.exports = scan;
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
/***/ }),
|
|
2057
|
-
|
|
2058
|
-
/***/ 473:
|
|
2059
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2060
|
-
|
|
2061
|
-
"use strict";
|
|
2062
|
-
/*global navigator*/
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
const {
|
|
2066
|
-
REGEX_BACKSLASH,
|
|
2067
|
-
REGEX_REMOVE_BACKSLASH,
|
|
2068
|
-
REGEX_SPECIAL_CHARS,
|
|
2069
|
-
REGEX_SPECIAL_CHARS_GLOBAL
|
|
2070
|
-
} = __nccwpck_require__(717);
|
|
2071
|
-
|
|
2072
|
-
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
2073
|
-
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
2074
|
-
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
2075
|
-
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
2076
|
-
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
2077
|
-
|
|
2078
|
-
exports.isWindows = () => {
|
|
2079
|
-
if (typeof navigator !== 'undefined' && navigator.platform) {
|
|
2080
|
-
const platform = navigator.platform.toLowerCase();
|
|
2081
|
-
return platform === 'win32' || platform === 'windows';
|
|
2082
|
-
}
|
|
2083
|
-
|
|
2084
|
-
if (typeof process !== 'undefined' && process.platform) {
|
|
2085
|
-
return process.platform === 'win32';
|
|
2086
|
-
}
|
|
2087
|
-
|
|
2088
|
-
return false;
|
|
2089
|
-
};
|
|
2090
|
-
|
|
2091
|
-
exports.removeBackslashes = str => {
|
|
2092
|
-
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
2093
|
-
return match === '\\' ? '' : match;
|
|
2094
|
-
});
|
|
2095
|
-
};
|
|
2096
|
-
|
|
2097
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
2098
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
2099
|
-
if (idx === -1) return input;
|
|
2100
|
-
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
2101
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
2102
|
-
};
|
|
2103
|
-
|
|
2104
|
-
exports.removePrefix = (input, state = {}) => {
|
|
2105
|
-
let output = input;
|
|
2106
|
-
if (output.startsWith('./')) {
|
|
2107
|
-
output = output.slice(2);
|
|
2108
|
-
state.prefix = './';
|
|
2109
|
-
}
|
|
2110
|
-
return output;
|
|
2111
|
-
};
|
|
2112
|
-
|
|
2113
|
-
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
2114
|
-
const prepend = options.contains ? '' : '^';
|
|
2115
|
-
const append = options.contains ? '' : '$';
|
|
2116
|
-
|
|
2117
|
-
let output = `${prepend}(?:${input})${append}`;
|
|
2118
|
-
if (state.negated === true) {
|
|
2119
|
-
output = `(?:^(?!${output}).*$)`;
|
|
2120
|
-
}
|
|
2121
|
-
return output;
|
|
2122
|
-
};
|
|
2123
|
-
|
|
2124
|
-
exports.basename = (path, { windows } = {}) => {
|
|
2125
|
-
const segs = path.split(windows ? /[\\/]/ : '/');
|
|
2126
|
-
const last = segs[segs.length - 1];
|
|
2127
|
-
|
|
2128
|
-
if (last === '') {
|
|
2129
|
-
return segs[segs.length - 2];
|
|
2130
|
-
}
|
|
2131
|
-
|
|
2132
|
-
return last;
|
|
2133
|
-
};
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
/***/ }),
|
|
2137
|
-
|
|
2138
|
-
/***/ 896:
|
|
2139
|
-
/***/ ((module) => {
|
|
2140
|
-
|
|
2141
|
-
"use strict";
|
|
2142
|
-
module.exports = require("fs");
|
|
2143
|
-
|
|
2144
|
-
/***/ }),
|
|
2145
|
-
|
|
2146
|
-
/***/ 928:
|
|
2147
|
-
/***/ ((module) => {
|
|
2148
|
-
|
|
2149
|
-
"use strict";
|
|
2150
|
-
module.exports = require("path");
|
|
2151
|
-
|
|
2152
|
-
/***/ }),
|
|
2153
|
-
|
|
2154
|
-
/***/ 278:
|
|
2155
|
-
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
|
2156
|
-
|
|
2157
|
-
//#region rolldown:runtime
|
|
2158
|
-
var __create = Object.create;
|
|
2159
|
-
var __defProp = Object.defineProperty;
|
|
2160
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2161
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2162
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
2163
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2164
|
-
var __copyProps = (to, from, except, desc) => {
|
|
2165
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
2166
|
-
key = keys[i];
|
|
2167
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
2168
|
-
get: ((k) => from[k]).bind(null, key),
|
|
2169
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
2170
|
-
});
|
|
2171
|
-
}
|
|
2172
|
-
return to;
|
|
2173
|
-
};
|
|
2174
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
2175
|
-
value: mod,
|
|
2176
|
-
enumerable: true
|
|
2177
|
-
}) : target, mod));
|
|
2178
|
-
|
|
2179
|
-
//#endregion
|
|
2180
|
-
const path = __toESM(__nccwpck_require__(928));
|
|
2181
|
-
const fs = __toESM(__nccwpck_require__(896));
|
|
2182
|
-
|
|
2183
|
-
//#region src/utils.ts
|
|
2184
|
-
function cleanPath(path$1) {
|
|
2185
|
-
let normalized = (0, path.normalize)(path$1);
|
|
2186
|
-
if (normalized.length > 1 && normalized[normalized.length - 1] === path.sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
2187
|
-
return normalized;
|
|
2188
|
-
}
|
|
2189
|
-
const SLASHES_REGEX = /[\\/]/g;
|
|
2190
|
-
function convertSlashes(path$1, separator) {
|
|
2191
|
-
return path$1.replace(SLASHES_REGEX, separator);
|
|
2192
|
-
}
|
|
2193
|
-
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
2194
|
-
function isRootDirectory(path$1) {
|
|
2195
|
-
return path$1 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$1);
|
|
2196
|
-
}
|
|
2197
|
-
function normalizePath(path$1, options) {
|
|
2198
|
-
const { resolvePaths, normalizePath: normalizePath$1, pathSeparator } = options;
|
|
2199
|
-
const pathNeedsCleaning = process.platform === "win32" && path$1.includes("/") || path$1.startsWith(".");
|
|
2200
|
-
if (resolvePaths) path$1 = (0, path.resolve)(path$1);
|
|
2201
|
-
if (normalizePath$1 || pathNeedsCleaning) path$1 = cleanPath(path$1);
|
|
2202
|
-
if (path$1 === ".") return "";
|
|
2203
|
-
const needsSeperator = path$1[path$1.length - 1] !== pathSeparator;
|
|
2204
|
-
return convertSlashes(needsSeperator ? path$1 + pathSeparator : path$1, pathSeparator);
|
|
2205
|
-
}
|
|
2206
|
-
|
|
2207
|
-
//#endregion
|
|
2208
|
-
//#region src/api/functions/join-path.ts
|
|
2209
|
-
function joinPathWithBasePath(filename, directoryPath) {
|
|
2210
|
-
return directoryPath + filename;
|
|
2211
|
-
}
|
|
2212
|
-
function joinPathWithRelativePath(root, options) {
|
|
2213
|
-
return function(filename, directoryPath) {
|
|
2214
|
-
const sameRoot = directoryPath.startsWith(root);
|
|
2215
|
-
if (sameRoot) return directoryPath.slice(root.length) + filename;
|
|
2216
|
-
else return convertSlashes((0, path.relative)(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
2217
|
-
};
|
|
2218
|
-
}
|
|
2219
|
-
function joinPath(filename) {
|
|
2220
|
-
return filename;
|
|
2221
|
-
}
|
|
2222
|
-
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
2223
|
-
return directoryPath + filename + separator;
|
|
2224
|
-
}
|
|
2225
|
-
function build$7(root, options) {
|
|
2226
|
-
const { relativePaths, includeBasePath } = options;
|
|
2227
|
-
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
//#endregion
|
|
2231
|
-
//#region src/api/functions/push-directory.ts
|
|
2232
|
-
function pushDirectoryWithRelativePath(root) {
|
|
2233
|
-
return function(directoryPath, paths) {
|
|
2234
|
-
paths.push(directoryPath.substring(root.length) || ".");
|
|
2235
|
-
};
|
|
2236
|
-
}
|
|
2237
|
-
function pushDirectoryFilterWithRelativePath(root) {
|
|
2238
|
-
return function(directoryPath, paths, filters) {
|
|
2239
|
-
const relativePath = directoryPath.substring(root.length) || ".";
|
|
2240
|
-
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
2241
|
-
};
|
|
2242
|
-
}
|
|
2243
|
-
const pushDirectory = (directoryPath, paths) => {
|
|
2244
|
-
paths.push(directoryPath || ".");
|
|
2245
|
-
};
|
|
2246
|
-
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
2247
|
-
const path$1 = directoryPath || ".";
|
|
2248
|
-
if (filters.every((filter) => filter(path$1, true))) paths.push(path$1);
|
|
2249
|
-
};
|
|
2250
|
-
const empty$2 = () => {};
|
|
2251
|
-
function build$6(root, options) {
|
|
2252
|
-
const { includeDirs, filters, relativePaths } = options;
|
|
2253
|
-
if (!includeDirs) return empty$2;
|
|
2254
|
-
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
2255
|
-
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
2256
|
-
}
|
|
2257
|
-
|
|
2258
|
-
//#endregion
|
|
2259
|
-
//#region src/api/functions/push-file.ts
|
|
2260
|
-
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
2261
|
-
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
2262
|
-
};
|
|
2263
|
-
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
2264
|
-
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
2265
|
-
};
|
|
2266
|
-
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
2267
|
-
counts.files++;
|
|
2268
|
-
};
|
|
2269
|
-
const pushFile = (filename, paths) => {
|
|
2270
|
-
paths.push(filename);
|
|
2271
|
-
};
|
|
2272
|
-
const empty$1 = () => {};
|
|
2273
|
-
function build$5(options) {
|
|
2274
|
-
const { excludeFiles, filters, onlyCounts } = options;
|
|
2275
|
-
if (excludeFiles) return empty$1;
|
|
2276
|
-
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
2277
|
-
else if (onlyCounts) return pushFileCount;
|
|
2278
|
-
else return pushFile;
|
|
2279
|
-
}
|
|
2280
|
-
|
|
2281
|
-
//#endregion
|
|
2282
|
-
//#region src/api/functions/get-array.ts
|
|
2283
|
-
const getArray = (paths) => {
|
|
2284
|
-
return paths;
|
|
2285
|
-
};
|
|
2286
|
-
const getArrayGroup = () => {
|
|
2287
|
-
return [""].slice(0, 0);
|
|
2288
|
-
};
|
|
2289
|
-
function build$4(options) {
|
|
2290
|
-
return options.group ? getArrayGroup : getArray;
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
//#endregion
|
|
2294
|
-
//#region src/api/functions/group-files.ts
|
|
2295
|
-
const groupFiles = (groups, directory, files) => {
|
|
2296
|
-
groups.push({
|
|
2297
|
-
directory,
|
|
2298
|
-
files,
|
|
2299
|
-
dir: directory
|
|
2300
|
-
});
|
|
2301
|
-
};
|
|
2302
|
-
const empty = () => {};
|
|
2303
|
-
function build$3(options) {
|
|
2304
|
-
return options.group ? groupFiles : empty;
|
|
2305
|
-
}
|
|
2306
|
-
|
|
2307
|
-
//#endregion
|
|
2308
|
-
//#region src/api/functions/resolve-symlink.ts
|
|
2309
|
-
const resolveSymlinksAsync = function(path$1, state, callback$1) {
|
|
2310
|
-
const { queue, fs: fs$1, options: { suppressErrors } } = state;
|
|
2311
|
-
queue.enqueue();
|
|
2312
|
-
fs$1.realpath(path$1, (error, resolvedPath) => {
|
|
2313
|
-
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
2314
|
-
fs$1.stat(resolvedPath, (error$1, stat) => {
|
|
2315
|
-
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
2316
|
-
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return queue.dequeue(null, state);
|
|
2317
|
-
callback$1(stat, resolvedPath);
|
|
2318
|
-
queue.dequeue(null, state);
|
|
2319
|
-
});
|
|
2320
|
-
});
|
|
2321
|
-
};
|
|
2322
|
-
const resolveSymlinks = function(path$1, state, callback$1) {
|
|
2323
|
-
const { queue, fs: fs$1, options: { suppressErrors } } = state;
|
|
2324
|
-
queue.enqueue();
|
|
2325
|
-
try {
|
|
2326
|
-
const resolvedPath = fs$1.realpathSync(path$1);
|
|
2327
|
-
const stat = fs$1.statSync(resolvedPath);
|
|
2328
|
-
if (stat.isDirectory() && isRecursive(path$1, resolvedPath, state)) return;
|
|
2329
|
-
callback$1(stat, resolvedPath);
|
|
2330
|
-
} catch (e) {
|
|
2331
|
-
if (!suppressErrors) throw e;
|
|
2332
|
-
}
|
|
2333
|
-
};
|
|
2334
|
-
function build$2(options, isSynchronous) {
|
|
2335
|
-
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
2336
|
-
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
2337
|
-
}
|
|
2338
|
-
function isRecursive(path$1, resolved, state) {
|
|
2339
|
-
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
2340
|
-
let parent = (0, path.dirname)(path$1);
|
|
2341
|
-
let depth = 1;
|
|
2342
|
-
while (parent !== state.root && depth < 2) {
|
|
2343
|
-
const resolvedPath = state.symlinks.get(parent);
|
|
2344
|
-
const isSameRoot = !!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath));
|
|
2345
|
-
if (isSameRoot) depth++;
|
|
2346
|
-
else parent = (0, path.dirname)(parent);
|
|
2347
|
-
}
|
|
2348
|
-
state.symlinks.set(path$1, resolved);
|
|
2349
|
-
return depth > 1;
|
|
2350
|
-
}
|
|
2351
|
-
function isRecursiveUsingRealPaths(resolved, state) {
|
|
2352
|
-
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
2353
|
-
}
|
|
2354
|
-
|
|
2355
|
-
//#endregion
|
|
2356
|
-
//#region src/api/functions/invoke-callback.ts
|
|
2357
|
-
const onlyCountsSync = (state) => {
|
|
2358
|
-
return state.counts;
|
|
2359
|
-
};
|
|
2360
|
-
const groupsSync = (state) => {
|
|
2361
|
-
return state.groups;
|
|
2362
|
-
};
|
|
2363
|
-
const defaultSync = (state) => {
|
|
2364
|
-
return state.paths;
|
|
2365
|
-
};
|
|
2366
|
-
const limitFilesSync = (state) => {
|
|
2367
|
-
return state.paths.slice(0, state.options.maxFiles);
|
|
2368
|
-
};
|
|
2369
|
-
const onlyCountsAsync = (state, error, callback$1) => {
|
|
2370
|
-
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
2371
|
-
return null;
|
|
2372
|
-
};
|
|
2373
|
-
const defaultAsync = (state, error, callback$1) => {
|
|
2374
|
-
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
2375
|
-
return null;
|
|
2376
|
-
};
|
|
2377
|
-
const limitFilesAsync = (state, error, callback$1) => {
|
|
2378
|
-
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
2379
|
-
return null;
|
|
2380
|
-
};
|
|
2381
|
-
const groupsAsync = (state, error, callback$1) => {
|
|
2382
|
-
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
2383
|
-
return null;
|
|
2384
|
-
};
|
|
2385
|
-
function report(error, callback$1, output, suppressErrors) {
|
|
2386
|
-
if (error && !suppressErrors) callback$1(error, output);
|
|
2387
|
-
else callback$1(null, output);
|
|
2388
|
-
}
|
|
2389
|
-
function build$1(options, isSynchronous) {
|
|
2390
|
-
const { onlyCounts, group, maxFiles } = options;
|
|
2391
|
-
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
2392
|
-
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
2393
|
-
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
2394
|
-
else return isSynchronous ? defaultSync : defaultAsync;
|
|
2395
|
-
}
|
|
2396
|
-
|
|
2397
|
-
//#endregion
|
|
2398
|
-
//#region src/api/functions/walk-directory.ts
|
|
2399
|
-
const readdirOpts = { withFileTypes: true };
|
|
2400
|
-
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
2401
|
-
state.queue.enqueue();
|
|
2402
|
-
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
2403
|
-
const { fs: fs$1 } = state;
|
|
2404
|
-
state.visited.push(crawlPath);
|
|
2405
|
-
state.counts.directories++;
|
|
2406
|
-
fs$1.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
2407
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
2408
|
-
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
2409
|
-
});
|
|
2410
|
-
};
|
|
2411
|
-
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
2412
|
-
const { fs: fs$1 } = state;
|
|
2413
|
-
if (currentDepth < 0) return;
|
|
2414
|
-
state.visited.push(crawlPath);
|
|
2415
|
-
state.counts.directories++;
|
|
2416
|
-
let entries = [];
|
|
2417
|
-
try {
|
|
2418
|
-
entries = fs$1.readdirSync(crawlPath || ".", readdirOpts);
|
|
2419
|
-
} catch (e) {
|
|
2420
|
-
if (!state.options.suppressErrors) throw e;
|
|
2421
|
-
}
|
|
2422
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
2423
|
-
};
|
|
2424
|
-
function build(isSynchronous) {
|
|
2425
|
-
return isSynchronous ? walkSync : walkAsync;
|
|
2426
|
-
}
|
|
2427
|
-
|
|
2428
|
-
//#endregion
|
|
2429
|
-
//#region src/api/queue.ts
|
|
2430
|
-
/**
|
|
2431
|
-
* This is a custom stateless queue to track concurrent async fs calls.
|
|
2432
|
-
* It increments a counter whenever a call is queued and decrements it
|
|
2433
|
-
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
2434
|
-
*/
|
|
2435
|
-
var Queue = class {
|
|
2436
|
-
count = 0;
|
|
2437
|
-
constructor(onQueueEmpty) {
|
|
2438
|
-
this.onQueueEmpty = onQueueEmpty;
|
|
2439
|
-
}
|
|
2440
|
-
enqueue() {
|
|
2441
|
-
this.count++;
|
|
2442
|
-
return this.count;
|
|
2443
|
-
}
|
|
2444
|
-
dequeue(error, output) {
|
|
2445
|
-
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
2446
|
-
this.onQueueEmpty(error, output);
|
|
2447
|
-
if (error) {
|
|
2448
|
-
output.controller.abort();
|
|
2449
|
-
this.onQueueEmpty = void 0;
|
|
2450
|
-
}
|
|
2451
|
-
}
|
|
2452
|
-
}
|
|
2453
|
-
};
|
|
2454
|
-
|
|
2455
|
-
//#endregion
|
|
2456
|
-
//#region src/api/counter.ts
|
|
2457
|
-
var Counter = class {
|
|
2458
|
-
_files = 0;
|
|
2459
|
-
_directories = 0;
|
|
2460
|
-
set files(num) {
|
|
2461
|
-
this._files = num;
|
|
2462
|
-
}
|
|
2463
|
-
get files() {
|
|
2464
|
-
return this._files;
|
|
2465
|
-
}
|
|
2466
|
-
set directories(num) {
|
|
2467
|
-
this._directories = num;
|
|
2468
|
-
}
|
|
2469
|
-
get directories() {
|
|
2470
|
-
return this._directories;
|
|
2471
|
-
}
|
|
2472
|
-
/**
|
|
2473
|
-
* @deprecated use `directories` instead
|
|
2474
|
-
*/
|
|
2475
|
-
/* c8 ignore next 3 */
|
|
2476
|
-
get dirs() {
|
|
2477
|
-
return this._directories;
|
|
2478
|
-
}
|
|
2479
|
-
};
|
|
2480
|
-
|
|
2481
|
-
//#endregion
|
|
2482
|
-
//#region src/api/aborter.ts
|
|
2483
|
-
/**
|
|
2484
|
-
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
2485
|
-
* support for Node 14.
|
|
2486
|
-
*/
|
|
2487
|
-
var Aborter = class {
|
|
2488
|
-
aborted = false;
|
|
2489
|
-
abort() {
|
|
2490
|
-
this.aborted = true;
|
|
2491
|
-
}
|
|
2492
|
-
};
|
|
2493
|
-
|
|
2494
|
-
//#endregion
|
|
2495
|
-
//#region src/api/walker.ts
|
|
2496
|
-
var Walker = class {
|
|
2497
|
-
root;
|
|
2498
|
-
isSynchronous;
|
|
2499
|
-
state;
|
|
2500
|
-
joinPath;
|
|
2501
|
-
pushDirectory;
|
|
2502
|
-
pushFile;
|
|
2503
|
-
getArray;
|
|
2504
|
-
groupFiles;
|
|
2505
|
-
resolveSymlink;
|
|
2506
|
-
walkDirectory;
|
|
2507
|
-
callbackInvoker;
|
|
2508
|
-
constructor(root, options, callback$1) {
|
|
2509
|
-
this.isSynchronous = !callback$1;
|
|
2510
|
-
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
2511
|
-
this.root = normalizePath(root, options);
|
|
2512
|
-
this.state = {
|
|
2513
|
-
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
2514
|
-
paths: [""].slice(0, 0),
|
|
2515
|
-
groups: [],
|
|
2516
|
-
counts: new Counter(),
|
|
2517
|
-
options,
|
|
2518
|
-
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
2519
|
-
symlinks: /* @__PURE__ */ new Map(),
|
|
2520
|
-
visited: [""].slice(0, 0),
|
|
2521
|
-
controller: new Aborter(),
|
|
2522
|
-
fs: options.fs || fs
|
|
2523
|
-
};
|
|
2524
|
-
this.joinPath = build$7(this.root, options);
|
|
2525
|
-
this.pushDirectory = build$6(this.root, options);
|
|
2526
|
-
this.pushFile = build$5(options);
|
|
2527
|
-
this.getArray = build$4(options);
|
|
2528
|
-
this.groupFiles = build$3(options);
|
|
2529
|
-
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
2530
|
-
this.walkDirectory = build(this.isSynchronous);
|
|
2531
|
-
}
|
|
2532
|
-
start() {
|
|
2533
|
-
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
2534
|
-
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
2535
|
-
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
2536
|
-
}
|
|
2537
|
-
walk = (entries, directoryPath, depth) => {
|
|
2538
|
-
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
2539
|
-
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
2540
|
-
const files = this.getArray(this.state.paths);
|
|
2541
|
-
for (let i = 0; i < entries.length; ++i) {
|
|
2542
|
-
const entry = entries[i];
|
|
2543
|
-
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
2544
|
-
const filename = this.joinPath(entry.name, directoryPath);
|
|
2545
|
-
this.pushFile(filename, files, this.state.counts, filters);
|
|
2546
|
-
} else if (entry.isDirectory()) {
|
|
2547
|
-
let path$1 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
2548
|
-
if (exclude && exclude(entry.name, path$1)) continue;
|
|
2549
|
-
this.pushDirectory(path$1, paths, filters);
|
|
2550
|
-
this.walkDirectory(this.state, path$1, path$1, depth - 1, this.walk);
|
|
2551
|
-
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
2552
|
-
let path$1 = joinPathWithBasePath(entry.name, directoryPath);
|
|
2553
|
-
this.resolveSymlink(path$1, this.state, (stat, resolvedPath) => {
|
|
2554
|
-
if (stat.isDirectory()) {
|
|
2555
|
-
resolvedPath = normalizePath(resolvedPath, this.state.options);
|
|
2556
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$1 + pathSeparator)) return;
|
|
2557
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$1 + pathSeparator, depth - 1, this.walk);
|
|
2558
|
-
} else {
|
|
2559
|
-
resolvedPath = useRealPaths ? resolvedPath : path$1;
|
|
2560
|
-
const filename = (0, path.basename)(resolvedPath);
|
|
2561
|
-
const directoryPath$1 = normalizePath((0, path.dirname)(resolvedPath), this.state.options);
|
|
2562
|
-
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
2563
|
-
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
2564
|
-
}
|
|
2565
|
-
});
|
|
2566
|
-
}
|
|
2567
|
-
}
|
|
2568
|
-
this.groupFiles(this.state.groups, directoryPath, files);
|
|
2569
|
-
};
|
|
2570
|
-
};
|
|
2571
|
-
|
|
2572
|
-
//#endregion
|
|
2573
|
-
//#region src/api/async.ts
|
|
2574
|
-
function promise(root, options) {
|
|
2575
|
-
return new Promise((resolve$1, reject) => {
|
|
2576
|
-
callback(root, options, (err, output) => {
|
|
2577
|
-
if (err) return reject(err);
|
|
2578
|
-
resolve$1(output);
|
|
2579
|
-
});
|
|
2580
|
-
});
|
|
2581
|
-
}
|
|
2582
|
-
function callback(root, options, callback$1) {
|
|
2583
|
-
let walker = new Walker(root, options, callback$1);
|
|
2584
|
-
walker.start();
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
//#endregion
|
|
2588
|
-
//#region src/api/sync.ts
|
|
2589
|
-
function sync(root, options) {
|
|
2590
|
-
const walker = new Walker(root, options);
|
|
2591
|
-
return walker.start();
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
|
-
//#endregion
|
|
2595
|
-
//#region src/builder/api-builder.ts
|
|
2596
|
-
var APIBuilder = class {
|
|
2597
|
-
constructor(root, options) {
|
|
2598
|
-
this.root = root;
|
|
2599
|
-
this.options = options;
|
|
2600
|
-
}
|
|
2601
|
-
withPromise() {
|
|
2602
|
-
return promise(this.root, this.options);
|
|
2603
|
-
}
|
|
2604
|
-
withCallback(cb) {
|
|
2605
|
-
callback(this.root, this.options, cb);
|
|
2606
|
-
}
|
|
2607
|
-
sync() {
|
|
2608
|
-
return sync(this.root, this.options);
|
|
2609
|
-
}
|
|
2610
|
-
};
|
|
2611
|
-
|
|
2612
|
-
//#endregion
|
|
2613
|
-
//#region src/builder/index.ts
|
|
2614
|
-
let pm = null;
|
|
2615
|
-
/* c8 ignore next 6 */
|
|
2616
|
-
try {
|
|
2617
|
-
/*require.resolve*/(676);
|
|
2618
|
-
pm = __nccwpck_require__(676);
|
|
2619
|
-
} catch {}
|
|
2620
|
-
var Builder = class {
|
|
2621
|
-
globCache = {};
|
|
2622
|
-
options = {
|
|
2623
|
-
maxDepth: Infinity,
|
|
2624
|
-
suppressErrors: true,
|
|
2625
|
-
pathSeparator: path.sep,
|
|
2626
|
-
filters: []
|
|
2627
|
-
};
|
|
2628
|
-
globFunction;
|
|
2629
|
-
constructor(options) {
|
|
2630
|
-
this.options = {
|
|
2631
|
-
...this.options,
|
|
2632
|
-
...options
|
|
2633
|
-
};
|
|
2634
|
-
this.globFunction = this.options.globFunction;
|
|
2635
|
-
}
|
|
2636
|
-
group() {
|
|
2637
|
-
this.options.group = true;
|
|
2638
|
-
return this;
|
|
2639
|
-
}
|
|
2640
|
-
withPathSeparator(separator) {
|
|
2641
|
-
this.options.pathSeparator = separator;
|
|
2642
|
-
return this;
|
|
2643
|
-
}
|
|
2644
|
-
withBasePath() {
|
|
2645
|
-
this.options.includeBasePath = true;
|
|
2646
|
-
return this;
|
|
2647
|
-
}
|
|
2648
|
-
withRelativePaths() {
|
|
2649
|
-
this.options.relativePaths = true;
|
|
2650
|
-
return this;
|
|
2651
|
-
}
|
|
2652
|
-
withDirs() {
|
|
2653
|
-
this.options.includeDirs = true;
|
|
2654
|
-
return this;
|
|
2655
|
-
}
|
|
2656
|
-
withMaxDepth(depth) {
|
|
2657
|
-
this.options.maxDepth = depth;
|
|
2658
|
-
return this;
|
|
2659
|
-
}
|
|
2660
|
-
withMaxFiles(limit) {
|
|
2661
|
-
this.options.maxFiles = limit;
|
|
2662
|
-
return this;
|
|
2663
|
-
}
|
|
2664
|
-
withFullPaths() {
|
|
2665
|
-
this.options.resolvePaths = true;
|
|
2666
|
-
this.options.includeBasePath = true;
|
|
2667
|
-
return this;
|
|
2668
|
-
}
|
|
2669
|
-
withErrors() {
|
|
2670
|
-
this.options.suppressErrors = false;
|
|
2671
|
-
return this;
|
|
2672
|
-
}
|
|
2673
|
-
withSymlinks({ resolvePaths = true } = {}) {
|
|
2674
|
-
this.options.resolveSymlinks = true;
|
|
2675
|
-
this.options.useRealPaths = resolvePaths;
|
|
2676
|
-
return this.withFullPaths();
|
|
2677
|
-
}
|
|
2678
|
-
withAbortSignal(signal) {
|
|
2679
|
-
this.options.signal = signal;
|
|
2680
|
-
return this;
|
|
2681
|
-
}
|
|
2682
|
-
normalize() {
|
|
2683
|
-
this.options.normalizePath = true;
|
|
2684
|
-
return this;
|
|
2685
|
-
}
|
|
2686
|
-
filter(predicate) {
|
|
2687
|
-
this.options.filters.push(predicate);
|
|
2688
|
-
return this;
|
|
2689
|
-
}
|
|
2690
|
-
onlyDirs() {
|
|
2691
|
-
this.options.excludeFiles = true;
|
|
2692
|
-
this.options.includeDirs = true;
|
|
2693
|
-
return this;
|
|
2694
|
-
}
|
|
2695
|
-
exclude(predicate) {
|
|
2696
|
-
this.options.exclude = predicate;
|
|
2697
|
-
return this;
|
|
2698
|
-
}
|
|
2699
|
-
onlyCounts() {
|
|
2700
|
-
this.options.onlyCounts = true;
|
|
2701
|
-
return this;
|
|
2702
|
-
}
|
|
2703
|
-
crawl(root) {
|
|
2704
|
-
return new APIBuilder(root || ".", this.options);
|
|
2705
|
-
}
|
|
2706
|
-
withGlobFunction(fn) {
|
|
2707
|
-
this.globFunction = fn;
|
|
2708
|
-
return this;
|
|
2709
|
-
}
|
|
2710
|
-
/**
|
|
2711
|
-
* @deprecated Pass options using the constructor instead:
|
|
2712
|
-
* ```ts
|
|
2713
|
-
* new fdir(options).crawl("/path/to/root");
|
|
2714
|
-
* ```
|
|
2715
|
-
* This method will be removed in v7.0
|
|
2716
|
-
*/
|
|
2717
|
-
/* c8 ignore next 4 */
|
|
2718
|
-
crawlWithOptions(root, options) {
|
|
2719
|
-
this.options = {
|
|
2720
|
-
...this.options,
|
|
2721
|
-
...options
|
|
2722
|
-
};
|
|
2723
|
-
return new APIBuilder(root || ".", this.options);
|
|
2724
|
-
}
|
|
2725
|
-
glob(...patterns) {
|
|
2726
|
-
if (this.globFunction) return this.globWithOptions(patterns);
|
|
2727
|
-
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
2728
|
-
}
|
|
2729
|
-
globWithOptions(patterns, ...options) {
|
|
2730
|
-
const globFn = this.globFunction || pm;
|
|
2731
|
-
/* c8 ignore next 5 */
|
|
2732
|
-
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
2733
|
-
var isMatch = this.globCache[patterns.join("\0")];
|
|
2734
|
-
if (!isMatch) {
|
|
2735
|
-
isMatch = globFn(patterns, ...options);
|
|
2736
|
-
this.globCache[patterns.join("\0")] = isMatch;
|
|
2737
|
-
}
|
|
2738
|
-
this.options.filters.push((path$1) => isMatch(path$1));
|
|
2739
|
-
return this;
|
|
2740
|
-
}
|
|
2741
|
-
};
|
|
2742
|
-
|
|
2743
|
-
//#endregion
|
|
2744
|
-
exports.fdir = Builder;
|
|
2745
|
-
|
|
2746
|
-
/***/ })
|
|
2747
|
-
|
|
2748
|
-
/******/ });
|
|
2749
|
-
/************************************************************************/
|
|
2750
|
-
/******/ // The module cache
|
|
2751
|
-
/******/ var __webpack_module_cache__ = {};
|
|
2752
|
-
/******/
|
|
2753
|
-
/******/ // The require function
|
|
2754
|
-
/******/ function __nccwpck_require__(moduleId) {
|
|
2755
|
-
/******/ // Check if module is in cache
|
|
2756
|
-
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
2757
|
-
/******/ if (cachedModule !== undefined) {
|
|
2758
|
-
/******/ return cachedModule.exports;
|
|
2759
|
-
/******/ }
|
|
2760
|
-
/******/ // Create a new module (and put it into the cache)
|
|
2761
|
-
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
2762
|
-
/******/ // no module.id needed
|
|
2763
|
-
/******/ // no module.loaded needed
|
|
2764
|
-
/******/ exports: {}
|
|
2765
|
-
/******/ };
|
|
2766
|
-
/******/
|
|
2767
|
-
/******/ // Execute the module function
|
|
2768
|
-
/******/ var threw = true;
|
|
2769
|
-
/******/ try {
|
|
2770
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
|
|
2771
|
-
/******/ threw = false;
|
|
2772
|
-
/******/ } finally {
|
|
2773
|
-
/******/ if(threw) delete __webpack_module_cache__[moduleId];
|
|
2774
|
-
/******/ }
|
|
2775
|
-
/******/
|
|
2776
|
-
/******/ // Return the exports of the module
|
|
2777
|
-
/******/ return module.exports;
|
|
2778
|
-
/******/ }
|
|
2779
|
-
/******/
|
|
2780
|
-
/************************************************************************/
|
|
2781
|
-
/******/ /* webpack/runtime/compat */
|
|
2782
|
-
/******/
|
|
2783
|
-
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
|
|
2784
|
-
/******/
|
|
2785
|
-
/************************************************************************/
|
|
2786
|
-
var __webpack_exports__ = {};
|
|
2787
|
-
// This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports).
|
|
2788
|
-
(() => {
|
|
2789
|
-
var exports = __webpack_exports__;
|
|
2790
|
-
//#region rolldown:runtime
|
|
2791
|
-
var __create = Object.create;
|
|
2792
|
-
var __defProp = Object.defineProperty;
|
|
2793
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2794
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2795
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
2796
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2797
|
-
var __copyProps = (to, from, except, desc) => {
|
|
2798
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
2799
|
-
key = keys[i];
|
|
2800
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
2801
|
-
get: ((k) => from[k]).bind(null, key),
|
|
2802
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
2803
|
-
});
|
|
2804
|
-
}
|
|
2805
|
-
return to;
|
|
2806
|
-
};
|
|
2807
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
2808
|
-
value: mod,
|
|
2809
|
-
enumerable: true
|
|
2810
|
-
}) : target, mod));
|
|
2811
|
-
|
|
2812
|
-
//#endregion
|
|
2813
|
-
const path = __toESM(__nccwpck_require__(928));
|
|
2814
|
-
const fdir = __toESM(__nccwpck_require__(278));
|
|
2815
|
-
const picomatch = __toESM(__nccwpck_require__(676));
|
|
2816
|
-
|
|
2817
|
-
//#region src/utils.ts
|
|
2818
|
-
const ONLY_PARENT_DIRECTORIES = /^(\/?\.\.)+$/;
|
|
2819
|
-
function getPartialMatcher(patterns, options) {
|
|
2820
|
-
const patternsCount = patterns.length;
|
|
2821
|
-
const patternsParts = Array(patternsCount);
|
|
2822
|
-
const regexes = Array(patternsCount);
|
|
2823
|
-
for (let i = 0; i < patternsCount; i++) {
|
|
2824
|
-
const parts = splitPattern(patterns[i]);
|
|
2825
|
-
patternsParts[i] = parts;
|
|
2826
|
-
const partsCount = parts.length;
|
|
2827
|
-
const partRegexes = Array(partsCount);
|
|
2828
|
-
for (let j = 0; j < partsCount; j++) partRegexes[j] = picomatch.default.makeRe(parts[j], options);
|
|
2829
|
-
regexes[i] = partRegexes;
|
|
2830
|
-
}
|
|
2831
|
-
return (input) => {
|
|
2832
|
-
const inputParts = input.split("/");
|
|
2833
|
-
if (inputParts[0] === ".." && ONLY_PARENT_DIRECTORIES.test(input)) return true;
|
|
2834
|
-
for (let i = 0; i < patterns.length; i++) {
|
|
2835
|
-
const patternParts = patternsParts[i];
|
|
2836
|
-
const regex = regexes[i];
|
|
2837
|
-
const inputPatternCount = inputParts.length;
|
|
2838
|
-
const minParts = Math.min(inputPatternCount, patternParts.length);
|
|
2839
|
-
let j = 0;
|
|
2840
|
-
while (j < minParts) {
|
|
2841
|
-
const part = patternParts[j];
|
|
2842
|
-
if (part.includes("/")) return true;
|
|
2843
|
-
const match = regex[j].test(inputParts[j]);
|
|
2844
|
-
if (!match) break;
|
|
2845
|
-
if (part === "**") return true;
|
|
2846
|
-
j++;
|
|
2847
|
-
}
|
|
2848
|
-
if (j === inputPatternCount) return true;
|
|
2849
|
-
}
|
|
2850
|
-
return false;
|
|
2851
|
-
};
|
|
2852
|
-
}
|
|
2853
|
-
const splitPatternOptions = { parts: true };
|
|
2854
|
-
function splitPattern(path$2) {
|
|
2855
|
-
var _result$parts;
|
|
2856
|
-
const result = picomatch.default.scan(path$2, splitPatternOptions);
|
|
2857
|
-
return ((_result$parts = result.parts) === null || _result$parts === void 0 ? void 0 : _result$parts.length) ? result.parts : [path$2];
|
|
2858
|
-
}
|
|
2859
|
-
const isWin = process.platform === "win32";
|
|
2860
|
-
const ESCAPED_WIN32_BACKSLASHES = /\\(?![()[\]{}!+@])/g;
|
|
2861
|
-
function convertPosixPathToPattern(path$2) {
|
|
2862
|
-
return escapePosixPath(path$2);
|
|
2863
|
-
}
|
|
2864
|
-
function convertWin32PathToPattern(path$2) {
|
|
2865
|
-
return escapeWin32Path(path$2).replace(ESCAPED_WIN32_BACKSLASHES, "/");
|
|
2866
|
-
}
|
|
2867
|
-
const convertPathToPattern = isWin ? convertWin32PathToPattern : convertPosixPathToPattern;
|
|
2868
|
-
const POSIX_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}*?|]|^!|[!+@](?=\()|\\(?![()[\]{}!*+?@|]))/g;
|
|
2869
|
-
const WIN32_UNESCAPED_GLOB_SYMBOLS = /(?<!\\)([()[\]{}]|^!|[!+@](?=\())/g;
|
|
2870
|
-
const escapePosixPath = (path$2) => path$2.replace(POSIX_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2871
|
-
const escapeWin32Path = (path$2) => path$2.replace(WIN32_UNESCAPED_GLOB_SYMBOLS, "\\$&");
|
|
2872
|
-
const escapePath = isWin ? escapeWin32Path : escapePosixPath;
|
|
2873
|
-
function isDynamicPattern(pattern, options) {
|
|
2874
|
-
if ((options === null || options === void 0 ? void 0 : options.caseSensitiveMatch) === false) return true;
|
|
2875
|
-
const scan = picomatch.default.scan(pattern);
|
|
2876
|
-
return scan.isGlob || scan.negated;
|
|
2877
|
-
}
|
|
2878
|
-
function log(...tasks) {
|
|
2879
|
-
console.log(`[tinyglobby ${new Date().toLocaleTimeString("es")}]`, ...tasks);
|
|
2880
|
-
}
|
|
2881
|
-
|
|
2882
|
-
//#endregion
|
|
2883
|
-
//#region src/index.ts
|
|
2884
|
-
const PARENT_DIRECTORY = /^(\/?\.\.)+/;
|
|
2885
|
-
const ESCAPING_BACKSLASHES = /\\(?=[()[\]{}!*+?@|])/g;
|
|
2886
|
-
const BACKSLASHES = /\\/g;
|
|
2887
|
-
function normalizePattern(pattern, expandDirectories, cwd, props, isIgnore) {
|
|
2888
|
-
let result = pattern;
|
|
2889
|
-
if (pattern.endsWith("/")) result = pattern.slice(0, -1);
|
|
2890
|
-
if (!result.endsWith("*") && expandDirectories) result += "/**";
|
|
2891
|
-
const escapedCwd = escapePath(cwd);
|
|
2892
|
-
if (path.default.isAbsolute(result.replace(ESCAPING_BACKSLASHES, ""))) result = path.posix.relative(escapedCwd, result);
|
|
2893
|
-
else result = path.posix.normalize(result);
|
|
2894
|
-
const parentDirectoryMatch = PARENT_DIRECTORY.exec(result);
|
|
2895
|
-
const parts = splitPattern(result);
|
|
2896
|
-
if (parentDirectoryMatch === null || parentDirectoryMatch === void 0 ? void 0 : parentDirectoryMatch[0]) {
|
|
2897
|
-
const n = (parentDirectoryMatch[0].length + 1) / 3;
|
|
2898
|
-
let i = 0;
|
|
2899
|
-
const cwdParts = escapedCwd.split("/");
|
|
2900
|
-
while (i < n && parts[i + n] === cwdParts[cwdParts.length + i - n]) {
|
|
2901
|
-
result = result.slice(0, (n - i - 1) * 3) + result.slice((n - i) * 3 + parts[i + n].length + 1) || ".";
|
|
2902
|
-
i++;
|
|
2903
|
-
}
|
|
2904
|
-
const potentialRoot = path.posix.join(cwd, parentDirectoryMatch[0].slice(i * 3));
|
|
2905
|
-
if (!potentialRoot.startsWith(".") && props.root.length > potentialRoot.length) {
|
|
2906
|
-
props.root = potentialRoot;
|
|
2907
|
-
props.depthOffset = -n + i;
|
|
2908
|
-
}
|
|
2909
|
-
}
|
|
2910
|
-
if (!isIgnore && props.depthOffset >= 0) {
|
|
2911
|
-
var _props$commonPath;
|
|
2912
|
-
(_props$commonPath = props.commonPath) !== null && _props$commonPath !== void 0 || (props.commonPath = parts);
|
|
2913
|
-
const newCommonPath = [];
|
|
2914
|
-
const length = Math.min(props.commonPath.length, parts.length);
|
|
2915
|
-
for (let i = 0; i < length; i++) {
|
|
2916
|
-
const part = parts[i];
|
|
2917
|
-
if (part === "**" && !parts[i + 1]) {
|
|
2918
|
-
newCommonPath.pop();
|
|
2919
|
-
break;
|
|
2920
|
-
}
|
|
2921
|
-
if (part !== props.commonPath[i] || isDynamicPattern(part) || i === parts.length - 1) break;
|
|
2922
|
-
newCommonPath.push(part);
|
|
2923
|
-
}
|
|
2924
|
-
props.depthOffset = newCommonPath.length;
|
|
2925
|
-
props.commonPath = newCommonPath;
|
|
2926
|
-
props.root = newCommonPath.length > 0 ? path.default.posix.join(cwd, ...newCommonPath) : cwd;
|
|
2927
|
-
}
|
|
2928
|
-
return result;
|
|
2929
|
-
}
|
|
2930
|
-
function processPatterns({ patterns, ignore = [], expandDirectories = true }, cwd, props) {
|
|
2931
|
-
if (typeof patterns === "string") patterns = [patterns];
|
|
2932
|
-
else if (!patterns) patterns = ["**/*"];
|
|
2933
|
-
if (typeof ignore === "string") ignore = [ignore];
|
|
2934
|
-
const matchPatterns = [];
|
|
2935
|
-
const ignorePatterns = [];
|
|
2936
|
-
for (const pattern of ignore) {
|
|
2937
|
-
if (!pattern) continue;
|
|
2938
|
-
if (pattern[0] !== "!" || pattern[1] === "(") ignorePatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, true));
|
|
2939
|
-
}
|
|
2940
|
-
for (const pattern of patterns) {
|
|
2941
|
-
if (!pattern) continue;
|
|
2942
|
-
if (pattern[0] !== "!" || pattern[1] === "(") matchPatterns.push(normalizePattern(pattern, expandDirectories, cwd, props, false));
|
|
2943
|
-
else if (pattern[1] !== "!" || pattern[2] === "(") ignorePatterns.push(normalizePattern(pattern.slice(1), expandDirectories, cwd, props, true));
|
|
2944
|
-
}
|
|
2945
|
-
return {
|
|
2946
|
-
match: matchPatterns,
|
|
2947
|
-
ignore: ignorePatterns
|
|
2948
|
-
};
|
|
2949
|
-
}
|
|
2950
|
-
function getRelativePath(path$2, cwd, root) {
|
|
2951
|
-
return path.posix.relative(cwd, `${root}/${path$2}`) || ".";
|
|
2952
|
-
}
|
|
2953
|
-
function processPath(path$2, cwd, root, isDirectory, absolute) {
|
|
2954
|
-
const relativePath = absolute ? path$2.slice(root === "/" ? 1 : root.length + 1) || "." : path$2;
|
|
2955
|
-
if (root === cwd) return isDirectory && relativePath !== "." ? relativePath.slice(0, -1) : relativePath;
|
|
2956
|
-
return getRelativePath(relativePath, cwd, root);
|
|
2957
|
-
}
|
|
2958
|
-
function formatPaths(paths, cwd, root) {
|
|
2959
|
-
for (let i = paths.length - 1; i >= 0; i--) {
|
|
2960
|
-
const path$2 = paths[i];
|
|
2961
|
-
paths[i] = getRelativePath(path$2, cwd, root) + (!path$2 || path$2.endsWith("/") ? "/" : "");
|
|
2962
|
-
}
|
|
2963
|
-
return paths;
|
|
2964
|
-
}
|
|
2965
|
-
function crawl(options, cwd, sync) {
|
|
2966
|
-
if (process.env.TINYGLOBBY_DEBUG) options.debug = true;
|
|
2967
|
-
if (options.debug) log("globbing with options:", options, "cwd:", cwd);
|
|
2968
|
-
if (Array.isArray(options.patterns) && options.patterns.length === 0) return sync ? [] : Promise.resolve([]);
|
|
2969
|
-
const props = {
|
|
2970
|
-
root: cwd,
|
|
2971
|
-
commonPath: null,
|
|
2972
|
-
depthOffset: 0
|
|
2973
|
-
};
|
|
2974
|
-
const processed = processPatterns(options, cwd, props);
|
|
2975
|
-
const nocase = options.caseSensitiveMatch === false;
|
|
2976
|
-
if (options.debug) log("internal processing patterns:", processed);
|
|
2977
|
-
const matcher = (0, picomatch.default)(processed.match, {
|
|
2978
|
-
dot: options.dot,
|
|
2979
|
-
nocase,
|
|
2980
|
-
ignore: processed.ignore
|
|
2981
|
-
});
|
|
2982
|
-
const ignore = (0, picomatch.default)(processed.ignore, {
|
|
2983
|
-
dot: options.dot,
|
|
2984
|
-
nocase
|
|
2985
|
-
});
|
|
2986
|
-
const partialMatcher = getPartialMatcher(processed.match, {
|
|
2987
|
-
dot: options.dot,
|
|
2988
|
-
nocase
|
|
2989
|
-
});
|
|
2990
|
-
const fdirOptions = {
|
|
2991
|
-
filters: [options.debug ? (p, isDirectory) => {
|
|
2992
|
-
const path$2 = processPath(p, cwd, props.root, isDirectory, options.absolute);
|
|
2993
|
-
const matches = matcher(path$2);
|
|
2994
|
-
if (matches) log(`matched ${path$2}`);
|
|
2995
|
-
return matches;
|
|
2996
|
-
} : (p, isDirectory) => matcher(processPath(p, cwd, props.root, isDirectory, options.absolute))],
|
|
2997
|
-
exclude: options.debug ? (_, p) => {
|
|
2998
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
2999
|
-
const skipped = relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
3000
|
-
if (skipped) log(`skipped ${p}`);
|
|
3001
|
-
else log(`crawling ${p}`);
|
|
3002
|
-
return skipped;
|
|
3003
|
-
} : (_, p) => {
|
|
3004
|
-
const relativePath = processPath(p, cwd, props.root, true, true);
|
|
3005
|
-
return relativePath !== "." && !partialMatcher(relativePath) || ignore(relativePath);
|
|
3006
|
-
},
|
|
3007
|
-
pathSeparator: "/",
|
|
3008
|
-
relativePaths: true,
|
|
3009
|
-
resolveSymlinks: true
|
|
3010
|
-
};
|
|
3011
|
-
if (options.deep !== void 0) fdirOptions.maxDepth = Math.round(options.deep - props.depthOffset);
|
|
3012
|
-
if (options.absolute) {
|
|
3013
|
-
fdirOptions.relativePaths = false;
|
|
3014
|
-
fdirOptions.resolvePaths = true;
|
|
3015
|
-
fdirOptions.includeBasePath = true;
|
|
3016
|
-
}
|
|
3017
|
-
if (options.followSymbolicLinks === false) {
|
|
3018
|
-
fdirOptions.resolveSymlinks = false;
|
|
3019
|
-
fdirOptions.excludeSymlinks = true;
|
|
3020
|
-
}
|
|
3021
|
-
if (options.onlyDirectories) {
|
|
3022
|
-
fdirOptions.excludeFiles = true;
|
|
3023
|
-
fdirOptions.includeDirs = true;
|
|
3024
|
-
} else if (options.onlyFiles === false) fdirOptions.includeDirs = true;
|
|
3025
|
-
props.root = props.root.replace(BACKSLASHES, "");
|
|
3026
|
-
const root = props.root;
|
|
3027
|
-
if (options.debug) log("internal properties:", props);
|
|
3028
|
-
const api = new fdir.fdir(fdirOptions).crawl(root);
|
|
3029
|
-
if (cwd === root || options.absolute) return sync ? api.sync() : api.withPromise();
|
|
3030
|
-
return sync ? formatPaths(api.sync(), cwd, root) : api.withPromise().then((paths) => formatPaths(paths, cwd, root));
|
|
3031
|
-
}
|
|
3032
|
-
async function glob(patternsOrOptions, options) {
|
|
3033
|
-
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
3034
|
-
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
|
3035
|
-
...options,
|
|
3036
|
-
patterns: patternsOrOptions
|
|
3037
|
-
} : patternsOrOptions;
|
|
3038
|
-
const cwd = opts.cwd ? path.default.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
3039
|
-
return crawl(opts, cwd, false);
|
|
3040
|
-
}
|
|
3041
|
-
function globSync(patternsOrOptions, options) {
|
|
3042
|
-
if (patternsOrOptions && (options === null || options === void 0 ? void 0 : options.patterns)) throw new Error("Cannot pass patterns as both an argument and an option");
|
|
3043
|
-
const opts = Array.isArray(patternsOrOptions) || typeof patternsOrOptions === "string" ? {
|
|
3044
|
-
...options,
|
|
3045
|
-
patterns: patternsOrOptions
|
|
3046
|
-
} : patternsOrOptions;
|
|
3047
|
-
const cwd = opts.cwd ? path.default.resolve(opts.cwd).replace(BACKSLASHES, "/") : process.cwd().replace(BACKSLASHES, "/");
|
|
3048
|
-
return crawl(opts, cwd, true);
|
|
3049
|
-
}
|
|
3050
|
-
|
|
3051
|
-
//#endregion
|
|
3052
|
-
exports.convertPathToPattern = convertPathToPattern;
|
|
3053
|
-
exports.escapePath = escapePath;
|
|
3054
|
-
exports.glob = glob;
|
|
3055
|
-
exports.globSync = globSync;
|
|
3056
|
-
exports.isDynamicPattern = isDynamicPattern;
|
|
3057
|
-
})();
|
|
3058
|
-
|
|
3059
|
-
module.exports = __webpack_exports__;
|
|
3060
|
-
/******/ })()
|
|
3061
|
-
;
|