nitro-nightly 3.0.1-20260106-122901-e9c3a660 → 3.0.1-20260106-130706-e20c92d9
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/dist/_build/rolldown.mjs +7 -9
- package/dist/_build/rollup.mjs +7 -9
- package/dist/_build/shared.mjs +1 -1
- package/dist/_build/shared3.mjs +1 -1
- package/dist/_build/shared4.mjs +10 -8
- package/dist/_build/vite.build.mjs +4 -6
- package/dist/_build/vite.plugin.mjs +5 -5
- package/dist/_dev.mjs +2 -2
- package/dist/_libs/@hiogawa/vite-plugin-fullstack.mjs +1 -1
- package/dist/_libs/@rollup/plugin-commonjs.mjs +2031 -2031
- package/dist/_libs/@rollup/plugin-inject.mjs +1 -1
- package/dist/_libs/@rollup/plugin-node-resolve.mjs +1 -1
- package/dist/_libs/@rollup/plugin-replace.mjs +1 -1
- package/dist/_libs/c12.mjs +1114 -1114
- package/dist/_libs/chokidar.mjs +2 -2
- package/dist/_libs/confbox.mjs +730 -730
- package/dist/_libs/giget.mjs +22 -22
- package/dist/_libs/local-pkg.mjs +5 -5
- package/dist/_libs/tinyglobby.mjs +1 -1
- package/dist/_libs/tsconfck.mjs +1 -1
- package/dist/_libs/unimport.mjs +209 -200
- package/dist/_libs/unwasm.mjs +2 -2
- package/dist/_nitro.mjs +5 -6
- package/dist/_nitro2.mjs +5 -6
- package/dist/_presets.mjs +7 -7
- package/dist/builder.mjs +4 -4
- package/dist/vite.mjs +4 -6
- package/package.json +1 -1
|
@@ -5,1252 +5,1761 @@ import { existsSync, readFileSync, statSync } from "fs";
|
|
|
5
5
|
import { basename, dirname, extname, isAbsolute, join, normalize, posix, relative, resolve, sep, win32 } from "path";
|
|
6
6
|
import { createRequire } from "module";
|
|
7
7
|
|
|
8
|
-
//#region node_modules/.pnpm/
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
STAR: `${QMARK}*?`,
|
|
39
|
-
START_ANCHOR,
|
|
40
|
-
SEP: "/"
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Windows glob regex
|
|
44
|
-
*/
|
|
45
|
-
const WINDOWS_CHARS = {
|
|
46
|
-
...POSIX_CHARS,
|
|
47
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
48
|
-
QMARK: WIN_NO_SLASH,
|
|
49
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
50
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
51
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
52
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
53
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
54
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
55
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
56
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
57
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
58
|
-
SEP: "\\"
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* POSIX Bracket Regex
|
|
62
|
-
*/
|
|
63
|
-
const POSIX_REGEX_SOURCE = {
|
|
64
|
-
alnum: "a-zA-Z0-9",
|
|
65
|
-
alpha: "a-zA-Z",
|
|
66
|
-
ascii: "\\x00-\\x7F",
|
|
67
|
-
blank: " \\t",
|
|
68
|
-
cntrl: "\\x00-\\x1F\\x7F",
|
|
69
|
-
digit: "0-9",
|
|
70
|
-
graph: "\\x21-\\x7E",
|
|
71
|
-
lower: "a-z",
|
|
72
|
-
print: "\\x20-\\x7E ",
|
|
73
|
-
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
74
|
-
space: " \\t\\r\\n\\v\\f",
|
|
75
|
-
upper: "A-Z",
|
|
76
|
-
word: "A-Za-z0-9_",
|
|
77
|
-
xdigit: "A-Fa-f0-9"
|
|
78
|
-
};
|
|
79
|
-
module.exports = {
|
|
80
|
-
MAX_LENGTH: 1024 * 64,
|
|
81
|
-
POSIX_REGEX_SOURCE,
|
|
82
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
83
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
84
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
85
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
86
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
87
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
88
|
-
REPLACEMENTS: {
|
|
89
|
-
__proto__: null,
|
|
90
|
-
"***": "*",
|
|
91
|
-
"**/**": "**",
|
|
92
|
-
"**/**/**": "**"
|
|
93
|
-
},
|
|
94
|
-
CHAR_0: 48,
|
|
95
|
-
CHAR_9: 57,
|
|
96
|
-
CHAR_UPPERCASE_A: 65,
|
|
97
|
-
CHAR_LOWERCASE_A: 97,
|
|
98
|
-
CHAR_UPPERCASE_Z: 90,
|
|
99
|
-
CHAR_LOWERCASE_Z: 122,
|
|
100
|
-
CHAR_LEFT_PARENTHESES: 40,
|
|
101
|
-
CHAR_RIGHT_PARENTHESES: 41,
|
|
102
|
-
CHAR_ASTERISK: 42,
|
|
103
|
-
CHAR_AMPERSAND: 38,
|
|
104
|
-
CHAR_AT: 64,
|
|
105
|
-
CHAR_BACKWARD_SLASH: 92,
|
|
106
|
-
CHAR_CARRIAGE_RETURN: 13,
|
|
107
|
-
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
108
|
-
CHAR_COLON: 58,
|
|
109
|
-
CHAR_COMMA: 44,
|
|
110
|
-
CHAR_DOT: 46,
|
|
111
|
-
CHAR_DOUBLE_QUOTE: 34,
|
|
112
|
-
CHAR_EQUAL: 61,
|
|
113
|
-
CHAR_EXCLAMATION_MARK: 33,
|
|
114
|
-
CHAR_FORM_FEED: 12,
|
|
115
|
-
CHAR_FORWARD_SLASH: 47,
|
|
116
|
-
CHAR_GRAVE_ACCENT: 96,
|
|
117
|
-
CHAR_HASH: 35,
|
|
118
|
-
CHAR_HYPHEN_MINUS: 45,
|
|
119
|
-
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
120
|
-
CHAR_LEFT_CURLY_BRACE: 123,
|
|
121
|
-
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
122
|
-
CHAR_LINE_FEED: 10,
|
|
123
|
-
CHAR_NO_BREAK_SPACE: 160,
|
|
124
|
-
CHAR_PERCENT: 37,
|
|
125
|
-
CHAR_PLUS: 43,
|
|
126
|
-
CHAR_QUESTION_MARK: 63,
|
|
127
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
128
|
-
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
129
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
130
|
-
CHAR_SEMICOLON: 59,
|
|
131
|
-
CHAR_SINGLE_QUOTE: 39,
|
|
132
|
-
CHAR_SPACE: 32,
|
|
133
|
-
CHAR_TAB: 9,
|
|
134
|
-
CHAR_UNDERSCORE: 95,
|
|
135
|
-
CHAR_VERTICAL_LINE: 124,
|
|
136
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
137
|
-
extglobChars(chars) {
|
|
138
|
-
return {
|
|
139
|
-
"!": {
|
|
140
|
-
type: "negate",
|
|
141
|
-
open: "(?:(?!(?:",
|
|
142
|
-
close: `))${chars.STAR})`
|
|
143
|
-
},
|
|
144
|
-
"?": {
|
|
145
|
-
type: "qmark",
|
|
146
|
-
open: "(?:",
|
|
147
|
-
close: ")?"
|
|
148
|
-
},
|
|
149
|
-
"+": {
|
|
150
|
-
type: "plus",
|
|
151
|
-
open: "(?:",
|
|
152
|
-
close: ")+"
|
|
153
|
-
},
|
|
154
|
-
"*": {
|
|
155
|
-
type: "star",
|
|
156
|
-
open: "(?:",
|
|
157
|
-
close: ")*"
|
|
158
|
-
},
|
|
159
|
-
"@": {
|
|
160
|
-
type: "at",
|
|
161
|
-
open: "(?:",
|
|
162
|
-
close: ")"
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
globChars(win32$1) {
|
|
167
|
-
return win32$1 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
//#endregion
|
|
173
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
174
|
-
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
175
|
-
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
176
|
-
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
177
|
-
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
178
|
-
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
179
|
-
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
180
|
-
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
181
|
-
exports.isWindows = () => {
|
|
182
|
-
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
183
|
-
const platform = navigator.platform.toLowerCase();
|
|
184
|
-
return platform === "win32" || platform === "windows";
|
|
185
|
-
}
|
|
186
|
-
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
|
|
187
|
-
return false;
|
|
188
|
-
};
|
|
189
|
-
exports.removeBackslashes = (str) => {
|
|
190
|
-
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
191
|
-
return match === "\\" ? "" : match;
|
|
192
|
-
});
|
|
193
|
-
};
|
|
194
|
-
exports.escapeLast = (input, char, lastIdx) => {
|
|
195
|
-
const idx = input.lastIndexOf(char, lastIdx);
|
|
196
|
-
if (idx === -1) return input;
|
|
197
|
-
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
198
|
-
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
8
|
+
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
9
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
10
|
+
function cleanPath(path$2) {
|
|
11
|
+
let normalized = normalize(path$2);
|
|
12
|
+
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
13
|
+
return normalized;
|
|
14
|
+
}
|
|
15
|
+
const SLASHES_REGEX = /[\\/]/g;
|
|
16
|
+
function convertSlashes(path$2, separator) {
|
|
17
|
+
return path$2.replace(SLASHES_REGEX, separator);
|
|
18
|
+
}
|
|
19
|
+
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
20
|
+
function isRootDirectory(path$2) {
|
|
21
|
+
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
22
|
+
}
|
|
23
|
+
function normalizePath$1(path$2, options) {
|
|
24
|
+
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
25
|
+
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
26
|
+
if (resolvePaths) path$2 = resolve(path$2);
|
|
27
|
+
if (normalizePath$1$1 || pathNeedsCleaning) path$2 = cleanPath(path$2);
|
|
28
|
+
if (path$2 === ".") return "";
|
|
29
|
+
return convertSlashes(path$2[path$2.length - 1] !== pathSeparator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
30
|
+
}
|
|
31
|
+
function joinPathWithBasePath(filename, directoryPath) {
|
|
32
|
+
return directoryPath + filename;
|
|
33
|
+
}
|
|
34
|
+
function joinPathWithRelativePath(root, options) {
|
|
35
|
+
return function(filename, directoryPath) {
|
|
36
|
+
if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
|
|
37
|
+
else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
199
38
|
};
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
39
|
+
}
|
|
40
|
+
function joinPath(filename) {
|
|
41
|
+
return filename;
|
|
42
|
+
}
|
|
43
|
+
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
44
|
+
return directoryPath + filename + separator;
|
|
45
|
+
}
|
|
46
|
+
function build$7(root, options) {
|
|
47
|
+
const { relativePaths, includeBasePath } = options;
|
|
48
|
+
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
49
|
+
}
|
|
50
|
+
function pushDirectoryWithRelativePath(root) {
|
|
51
|
+
return function(directoryPath, paths) {
|
|
52
|
+
paths.push(directoryPath.substring(root.length) || ".");
|
|
207
53
|
};
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
exports.basename = (path$2, { windows } = {}) => {
|
|
214
|
-
const segs = path$2.split(windows ? /[\\/]/ : "/");
|
|
215
|
-
const last = segs[segs.length - 1];
|
|
216
|
-
if (last === "") return segs[segs.length - 2];
|
|
217
|
-
return last;
|
|
218
|
-
};
|
|
219
|
-
}));
|
|
220
|
-
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
223
|
-
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
224
|
-
const utils = require_utils();
|
|
225
|
-
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
226
|
-
const isPathSeparator = (code) => {
|
|
227
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
228
|
-
};
|
|
229
|
-
const depth = (token) => {
|
|
230
|
-
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
54
|
+
}
|
|
55
|
+
function pushDirectoryFilterWithRelativePath(root) {
|
|
56
|
+
return function(directoryPath, paths, filters) {
|
|
57
|
+
const relativePath = directoryPath.substring(root.length) || ".";
|
|
58
|
+
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
231
59
|
};
|
|
60
|
+
}
|
|
61
|
+
const pushDirectory = (directoryPath, paths) => {
|
|
62
|
+
paths.push(directoryPath || ".");
|
|
63
|
+
};
|
|
64
|
+
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
65
|
+
const path$2 = directoryPath || ".";
|
|
66
|
+
if (filters.every((filter) => filter(path$2, true))) paths.push(path$2);
|
|
67
|
+
};
|
|
68
|
+
const empty$2 = () => {};
|
|
69
|
+
function build$6(root, options) {
|
|
70
|
+
const { includeDirs, filters, relativePaths } = options;
|
|
71
|
+
if (!includeDirs) return empty$2;
|
|
72
|
+
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
73
|
+
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
74
|
+
}
|
|
75
|
+
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
76
|
+
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
77
|
+
};
|
|
78
|
+
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
79
|
+
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
80
|
+
};
|
|
81
|
+
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
82
|
+
counts.files++;
|
|
83
|
+
};
|
|
84
|
+
const pushFile = (filename, paths) => {
|
|
85
|
+
paths.push(filename);
|
|
86
|
+
};
|
|
87
|
+
const empty$1 = () => {};
|
|
88
|
+
function build$5(options) {
|
|
89
|
+
const { excludeFiles, filters, onlyCounts } = options;
|
|
90
|
+
if (excludeFiles) return empty$1;
|
|
91
|
+
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
92
|
+
else if (onlyCounts) return pushFileCount;
|
|
93
|
+
else return pushFile;
|
|
94
|
+
}
|
|
95
|
+
const getArray = (paths) => {
|
|
96
|
+
return paths;
|
|
97
|
+
};
|
|
98
|
+
const getArrayGroup = () => {
|
|
99
|
+
return [""].slice(0, 0);
|
|
100
|
+
};
|
|
101
|
+
function build$4(options) {
|
|
102
|
+
return options.group ? getArrayGroup : getArray;
|
|
103
|
+
}
|
|
104
|
+
const groupFiles = (groups, directory, files) => {
|
|
105
|
+
groups.push({
|
|
106
|
+
directory,
|
|
107
|
+
files,
|
|
108
|
+
dir: directory
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
const empty = () => {};
|
|
112
|
+
function build$3(options) {
|
|
113
|
+
return options.group ? groupFiles : empty;
|
|
114
|
+
}
|
|
115
|
+
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
116
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
117
|
+
queue.enqueue();
|
|
118
|
+
fs.realpath(path$2, (error, resolvedPath) => {
|
|
119
|
+
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
120
|
+
fs.stat(resolvedPath, (error$1, stat) => {
|
|
121
|
+
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
122
|
+
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return queue.dequeue(null, state);
|
|
123
|
+
callback$1(stat, resolvedPath);
|
|
124
|
+
queue.dequeue(null, state);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
};
|
|
128
|
+
const resolveSymlinks = function(path$2, state, callback$1) {
|
|
129
|
+
const { queue, fs, options: { suppressErrors } } = state;
|
|
130
|
+
queue.enqueue();
|
|
131
|
+
try {
|
|
132
|
+
const resolvedPath = fs.realpathSync(path$2);
|
|
133
|
+
const stat = fs.statSync(resolvedPath);
|
|
134
|
+
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return;
|
|
135
|
+
callback$1(stat, resolvedPath);
|
|
136
|
+
} catch (e) {
|
|
137
|
+
if (!suppressErrors) throw e;
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
function build$2(options, isSynchronous) {
|
|
141
|
+
if (!options.resolveSymlinks || options.excludeSymlinks) return null;
|
|
142
|
+
return isSynchronous ? resolveSymlinks : resolveSymlinksAsync;
|
|
143
|
+
}
|
|
144
|
+
function isRecursive(path$2, resolved, state) {
|
|
145
|
+
if (state.options.useRealPaths) return isRecursiveUsingRealPaths(resolved, state);
|
|
146
|
+
let parent = dirname(path$2);
|
|
147
|
+
let depth = 1;
|
|
148
|
+
while (parent !== state.root && depth < 2) {
|
|
149
|
+
const resolvedPath = state.symlinks.get(parent);
|
|
150
|
+
if (!!resolvedPath && (resolvedPath === resolved || resolvedPath.startsWith(resolved) || resolved.startsWith(resolvedPath))) depth++;
|
|
151
|
+
else parent = dirname(parent);
|
|
152
|
+
}
|
|
153
|
+
state.symlinks.set(path$2, resolved);
|
|
154
|
+
return depth > 1;
|
|
155
|
+
}
|
|
156
|
+
function isRecursiveUsingRealPaths(resolved, state) {
|
|
157
|
+
return state.visited.includes(resolved + state.options.pathSeparator);
|
|
158
|
+
}
|
|
159
|
+
const onlyCountsSync = (state) => {
|
|
160
|
+
return state.counts;
|
|
161
|
+
};
|
|
162
|
+
const groupsSync = (state) => {
|
|
163
|
+
return state.groups;
|
|
164
|
+
};
|
|
165
|
+
const defaultSync = (state) => {
|
|
166
|
+
return state.paths;
|
|
167
|
+
};
|
|
168
|
+
const limitFilesSync = (state) => {
|
|
169
|
+
return state.paths.slice(0, state.options.maxFiles);
|
|
170
|
+
};
|
|
171
|
+
const onlyCountsAsync = (state, error, callback$1) => {
|
|
172
|
+
report(error, callback$1, state.counts, state.options.suppressErrors);
|
|
173
|
+
return null;
|
|
174
|
+
};
|
|
175
|
+
const defaultAsync = (state, error, callback$1) => {
|
|
176
|
+
report(error, callback$1, state.paths, state.options.suppressErrors);
|
|
177
|
+
return null;
|
|
178
|
+
};
|
|
179
|
+
const limitFilesAsync = (state, error, callback$1) => {
|
|
180
|
+
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
181
|
+
return null;
|
|
182
|
+
};
|
|
183
|
+
const groupsAsync = (state, error, callback$1) => {
|
|
184
|
+
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
185
|
+
return null;
|
|
186
|
+
};
|
|
187
|
+
function report(error, callback$1, output, suppressErrors) {
|
|
188
|
+
if (error && !suppressErrors) callback$1(error, output);
|
|
189
|
+
else callback$1(null, output);
|
|
190
|
+
}
|
|
191
|
+
function build$1(options, isSynchronous) {
|
|
192
|
+
const { onlyCounts, group, maxFiles } = options;
|
|
193
|
+
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
194
|
+
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
195
|
+
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
196
|
+
else return isSynchronous ? defaultSync : defaultAsync;
|
|
197
|
+
}
|
|
198
|
+
const readdirOpts = { withFileTypes: true };
|
|
199
|
+
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
200
|
+
state.queue.enqueue();
|
|
201
|
+
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
202
|
+
const { fs } = state;
|
|
203
|
+
state.visited.push(crawlPath);
|
|
204
|
+
state.counts.directories++;
|
|
205
|
+
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
206
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
207
|
+
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
208
|
+
});
|
|
209
|
+
};
|
|
210
|
+
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
211
|
+
const { fs } = state;
|
|
212
|
+
if (currentDepth < 0) return;
|
|
213
|
+
state.visited.push(crawlPath);
|
|
214
|
+
state.counts.directories++;
|
|
215
|
+
let entries = [];
|
|
216
|
+
try {
|
|
217
|
+
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
218
|
+
} catch (e) {
|
|
219
|
+
if (!state.options.suppressErrors) throw e;
|
|
220
|
+
}
|
|
221
|
+
callback$1(entries, directoryPath, currentDepth);
|
|
222
|
+
};
|
|
223
|
+
function build(isSynchronous) {
|
|
224
|
+
return isSynchronous ? walkSync : walkAsync;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* This is a custom stateless queue to track concurrent async fs calls.
|
|
228
|
+
* It increments a counter whenever a call is queued and decrements it
|
|
229
|
+
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
230
|
+
*/
|
|
231
|
+
var Queue = class {
|
|
232
|
+
count = 0;
|
|
233
|
+
constructor(onQueueEmpty) {
|
|
234
|
+
this.onQueueEmpty = onQueueEmpty;
|
|
235
|
+
}
|
|
236
|
+
enqueue() {
|
|
237
|
+
this.count++;
|
|
238
|
+
return this.count;
|
|
239
|
+
}
|
|
240
|
+
dequeue(error, output) {
|
|
241
|
+
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
242
|
+
this.onQueueEmpty(error, output);
|
|
243
|
+
if (error) {
|
|
244
|
+
output.controller.abort();
|
|
245
|
+
this.onQueueEmpty = void 0;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
var Counter = class {
|
|
251
|
+
_files = 0;
|
|
252
|
+
_directories = 0;
|
|
253
|
+
set files(num) {
|
|
254
|
+
this._files = num;
|
|
255
|
+
}
|
|
256
|
+
get files() {
|
|
257
|
+
return this._files;
|
|
258
|
+
}
|
|
259
|
+
set directories(num) {
|
|
260
|
+
this._directories = num;
|
|
261
|
+
}
|
|
262
|
+
get directories() {
|
|
263
|
+
return this._directories;
|
|
264
|
+
}
|
|
232
265
|
/**
|
|
233
|
-
*
|
|
234
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
235
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
236
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
237
|
-
*
|
|
238
|
-
* ```js
|
|
239
|
-
* const pm = require('picomatch');
|
|
240
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
241
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
242
|
-
* ```
|
|
243
|
-
* @param {String} `str`
|
|
244
|
-
* @param {Object} `options`
|
|
245
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
246
|
-
* @api public
|
|
266
|
+
* @deprecated use `directories` instead
|
|
247
267
|
*/
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
268
|
+
/* c8 ignore next 3 */
|
|
269
|
+
get dirs() {
|
|
270
|
+
return this._directories;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
/**
|
|
274
|
+
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
275
|
+
* support for Node 14.
|
|
276
|
+
*/
|
|
277
|
+
var Aborter = class {
|
|
278
|
+
aborted = false;
|
|
279
|
+
abort() {
|
|
280
|
+
this.aborted = true;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
var Walker = class {
|
|
284
|
+
root;
|
|
285
|
+
isSynchronous;
|
|
286
|
+
state;
|
|
287
|
+
joinPath;
|
|
288
|
+
pushDirectory;
|
|
289
|
+
pushFile;
|
|
290
|
+
getArray;
|
|
291
|
+
groupFiles;
|
|
292
|
+
resolveSymlink;
|
|
293
|
+
walkDirectory;
|
|
294
|
+
callbackInvoker;
|
|
295
|
+
constructor(root, options, callback$1) {
|
|
296
|
+
this.isSynchronous = !callback$1;
|
|
297
|
+
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
298
|
+
this.root = normalizePath$1(root, options);
|
|
299
|
+
this.state = {
|
|
300
|
+
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
301
|
+
paths: [""].slice(0, 0),
|
|
302
|
+
groups: [],
|
|
303
|
+
counts: new Counter(),
|
|
304
|
+
options,
|
|
305
|
+
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
306
|
+
symlinks: /* @__PURE__ */ new Map(),
|
|
307
|
+
visited: [""].slice(0, 0),
|
|
308
|
+
controller: new Aborter(),
|
|
309
|
+
fs: options.fs || nativeFs$1
|
|
282
310
|
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
finished = true;
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
if (scanToEnd === true) continue;
|
|
329
|
-
break;
|
|
330
|
-
}
|
|
331
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
332
|
-
slashes.push(index);
|
|
333
|
-
tokens.push(token);
|
|
334
|
-
token = {
|
|
335
|
-
value: "",
|
|
336
|
-
depth: 0,
|
|
337
|
-
isGlob: false
|
|
338
|
-
};
|
|
339
|
-
if (finished === true) continue;
|
|
340
|
-
if (prev === CHAR_DOT && index === start + 1) {
|
|
341
|
-
start += 2;
|
|
342
|
-
continue;
|
|
343
|
-
}
|
|
344
|
-
lastIndex = index + 1;
|
|
345
|
-
continue;
|
|
346
|
-
}
|
|
347
|
-
if (opts.noext !== true) {
|
|
348
|
-
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
349
|
-
isGlob = token.isGlob = true;
|
|
350
|
-
isExtglob = token.isExtglob = true;
|
|
351
|
-
finished = true;
|
|
352
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
353
|
-
if (scanToEnd === true) {
|
|
354
|
-
while (eos() !== true && (code = advance())) {
|
|
355
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
356
|
-
backslashes = token.backslashes = true;
|
|
357
|
-
code = advance();
|
|
358
|
-
continue;
|
|
359
|
-
}
|
|
360
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
361
|
-
isGlob = token.isGlob = true;
|
|
362
|
-
finished = true;
|
|
363
|
-
break;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
continue;
|
|
367
|
-
}
|
|
368
|
-
break;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (code === CHAR_ASTERISK) {
|
|
372
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
373
|
-
isGlob = token.isGlob = true;
|
|
374
|
-
finished = true;
|
|
375
|
-
if (scanToEnd === true) continue;
|
|
376
|
-
break;
|
|
377
|
-
}
|
|
378
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
379
|
-
isGlob = token.isGlob = true;
|
|
380
|
-
finished = true;
|
|
381
|
-
if (scanToEnd === true) continue;
|
|
382
|
-
break;
|
|
383
|
-
}
|
|
384
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
385
|
-
while (eos() !== true && (next = advance())) {
|
|
386
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
387
|
-
backslashes = token.backslashes = true;
|
|
388
|
-
advance();
|
|
389
|
-
continue;
|
|
390
|
-
}
|
|
391
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
392
|
-
isBracket = token.isBracket = true;
|
|
393
|
-
isGlob = token.isGlob = true;
|
|
394
|
-
finished = true;
|
|
395
|
-
break;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
if (scanToEnd === true) continue;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
402
|
-
negated = token.negated = true;
|
|
403
|
-
start++;
|
|
404
|
-
continue;
|
|
405
|
-
}
|
|
406
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
407
|
-
isGlob = token.isGlob = true;
|
|
408
|
-
if (scanToEnd === true) {
|
|
409
|
-
while (eos() !== true && (code = advance())) {
|
|
410
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
411
|
-
backslashes = token.backslashes = true;
|
|
412
|
-
code = advance();
|
|
413
|
-
continue;
|
|
414
|
-
}
|
|
415
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
416
|
-
finished = true;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
311
|
+
this.joinPath = build$7(this.root, options);
|
|
312
|
+
this.pushDirectory = build$6(this.root, options);
|
|
313
|
+
this.pushFile = build$5(options);
|
|
314
|
+
this.getArray = build$4(options);
|
|
315
|
+
this.groupFiles = build$3(options);
|
|
316
|
+
this.resolveSymlink = build$2(options, this.isSynchronous);
|
|
317
|
+
this.walkDirectory = build(this.isSynchronous);
|
|
318
|
+
}
|
|
319
|
+
start() {
|
|
320
|
+
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
321
|
+
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
322
|
+
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
323
|
+
}
|
|
324
|
+
walk = (entries, directoryPath, depth) => {
|
|
325
|
+
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
326
|
+
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
327
|
+
const files = this.getArray(this.state.paths);
|
|
328
|
+
for (let i = 0; i < entries.length; ++i) {
|
|
329
|
+
const entry = entries[i];
|
|
330
|
+
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
331
|
+
const filename = this.joinPath(entry.name, directoryPath);
|
|
332
|
+
this.pushFile(filename, files, this.state.counts, filters);
|
|
333
|
+
} else if (entry.isDirectory()) {
|
|
334
|
+
let path$2 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
335
|
+
if (exclude && exclude(entry.name, path$2)) continue;
|
|
336
|
+
this.pushDirectory(path$2, paths, filters);
|
|
337
|
+
this.walkDirectory(this.state, path$2, path$2, depth - 1, this.walk);
|
|
338
|
+
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
339
|
+
let path$2 = joinPathWithBasePath(entry.name, directoryPath);
|
|
340
|
+
this.resolveSymlink(path$2, this.state, (stat, resolvedPath) => {
|
|
341
|
+
if (stat.isDirectory()) {
|
|
342
|
+
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
343
|
+
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$2 + pathSeparator)) return;
|
|
344
|
+
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$2 + pathSeparator, depth - 1, this.walk);
|
|
345
|
+
} else {
|
|
346
|
+
resolvedPath = useRealPaths ? resolvedPath : path$2;
|
|
347
|
+
const filename = basename(resolvedPath);
|
|
348
|
+
const directoryPath$1 = normalizePath$1(dirname(resolvedPath), this.state.options);
|
|
349
|
+
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
350
|
+
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
419
351
|
}
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
break;
|
|
423
|
-
}
|
|
424
|
-
if (isGlob === true) {
|
|
425
|
-
finished = true;
|
|
426
|
-
if (scanToEnd === true) continue;
|
|
427
|
-
break;
|
|
352
|
+
});
|
|
428
353
|
}
|
|
429
354
|
}
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
355
|
+
this.groupFiles(this.state.groups, directoryPath, files);
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
function promise(root, options) {
|
|
359
|
+
return new Promise((resolve$1, reject) => {
|
|
360
|
+
callback(root, options, (err, output) => {
|
|
361
|
+
if (err) return reject(err);
|
|
362
|
+
resolve$1(output);
|
|
363
|
+
});
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function callback(root, options, callback$1) {
|
|
367
|
+
new Walker(root, options, callback$1).start();
|
|
368
|
+
}
|
|
369
|
+
function sync(root, options) {
|
|
370
|
+
return new Walker(root, options).start();
|
|
371
|
+
}
|
|
372
|
+
var APIBuilder = class {
|
|
373
|
+
constructor(root, options) {
|
|
374
|
+
this.root = root;
|
|
375
|
+
this.options = options;
|
|
376
|
+
}
|
|
377
|
+
withPromise() {
|
|
378
|
+
return promise(this.root, this.options);
|
|
379
|
+
}
|
|
380
|
+
withCallback(cb) {
|
|
381
|
+
callback(this.root, this.options, cb);
|
|
382
|
+
}
|
|
383
|
+
sync() {
|
|
384
|
+
return sync(this.root, this.options);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
let pm$1 = null;
|
|
388
|
+
/* c8 ignore next 6 */
|
|
389
|
+
try {
|
|
390
|
+
__require.resolve("picomatch");
|
|
391
|
+
pm$1 = __require("picomatch");
|
|
392
|
+
} catch {}
|
|
393
|
+
var Builder = class {
|
|
394
|
+
globCache = {};
|
|
395
|
+
options = {
|
|
396
|
+
maxDepth: Infinity,
|
|
397
|
+
suppressErrors: true,
|
|
398
|
+
pathSeparator: sep,
|
|
399
|
+
filters: []
|
|
400
|
+
};
|
|
401
|
+
globFunction;
|
|
402
|
+
constructor(options) {
|
|
403
|
+
this.options = {
|
|
404
|
+
...this.options,
|
|
405
|
+
...options
|
|
469
406
|
};
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
407
|
+
this.globFunction = this.options.globFunction;
|
|
408
|
+
}
|
|
409
|
+
group() {
|
|
410
|
+
this.options.group = true;
|
|
411
|
+
return this;
|
|
412
|
+
}
|
|
413
|
+
withPathSeparator(separator) {
|
|
414
|
+
this.options.pathSeparator = separator;
|
|
415
|
+
return this;
|
|
416
|
+
}
|
|
417
|
+
withBasePath() {
|
|
418
|
+
this.options.includeBasePath = true;
|
|
419
|
+
return this;
|
|
420
|
+
}
|
|
421
|
+
withRelativePaths() {
|
|
422
|
+
this.options.relativePaths = true;
|
|
423
|
+
return this;
|
|
424
|
+
}
|
|
425
|
+
withDirs() {
|
|
426
|
+
this.options.includeDirs = true;
|
|
427
|
+
return this;
|
|
428
|
+
}
|
|
429
|
+
withMaxDepth(depth) {
|
|
430
|
+
this.options.maxDepth = depth;
|
|
431
|
+
return this;
|
|
432
|
+
}
|
|
433
|
+
withMaxFiles(limit) {
|
|
434
|
+
this.options.maxFiles = limit;
|
|
435
|
+
return this;
|
|
436
|
+
}
|
|
437
|
+
withFullPaths() {
|
|
438
|
+
this.options.resolvePaths = true;
|
|
439
|
+
this.options.includeBasePath = true;
|
|
440
|
+
return this;
|
|
441
|
+
}
|
|
442
|
+
withErrors() {
|
|
443
|
+
this.options.suppressErrors = false;
|
|
444
|
+
return this;
|
|
445
|
+
}
|
|
446
|
+
withSymlinks({ resolvePaths = true } = {}) {
|
|
447
|
+
this.options.resolveSymlinks = true;
|
|
448
|
+
this.options.useRealPaths = resolvePaths;
|
|
449
|
+
return this.withFullPaths();
|
|
450
|
+
}
|
|
451
|
+
withAbortSignal(signal) {
|
|
452
|
+
this.options.signal = signal;
|
|
453
|
+
return this;
|
|
454
|
+
}
|
|
455
|
+
normalize() {
|
|
456
|
+
this.options.normalizePath = true;
|
|
457
|
+
return this;
|
|
458
|
+
}
|
|
459
|
+
filter(predicate) {
|
|
460
|
+
this.options.filters.push(predicate);
|
|
461
|
+
return this;
|
|
462
|
+
}
|
|
463
|
+
onlyDirs() {
|
|
464
|
+
this.options.excludeFiles = true;
|
|
465
|
+
this.options.includeDirs = true;
|
|
466
|
+
return this;
|
|
467
|
+
}
|
|
468
|
+
exclude(predicate) {
|
|
469
|
+
this.options.exclude = predicate;
|
|
470
|
+
return this;
|
|
471
|
+
}
|
|
472
|
+
onlyCounts() {
|
|
473
|
+
this.options.onlyCounts = true;
|
|
474
|
+
return this;
|
|
475
|
+
}
|
|
476
|
+
crawl(root) {
|
|
477
|
+
return new APIBuilder(root || ".", this.options);
|
|
478
|
+
}
|
|
479
|
+
withGlobFunction(fn) {
|
|
480
|
+
this.globFunction = fn;
|
|
481
|
+
return this;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* @deprecated Pass options using the constructor instead:
|
|
485
|
+
* ```ts
|
|
486
|
+
* new fdir(options).crawl("/path/to/root");
|
|
487
|
+
* ```
|
|
488
|
+
* This method will be removed in v7.0
|
|
489
|
+
*/
|
|
490
|
+
/* c8 ignore next 4 */
|
|
491
|
+
crawlWithOptions(root, options) {
|
|
492
|
+
this.options = {
|
|
493
|
+
...this.options,
|
|
494
|
+
...options
|
|
495
|
+
};
|
|
496
|
+
return new APIBuilder(root || ".", this.options);
|
|
497
|
+
}
|
|
498
|
+
glob(...patterns) {
|
|
499
|
+
if (this.globFunction) return this.globWithOptions(patterns);
|
|
500
|
+
return this.globWithOptions(patterns, ...[{ dot: true }]);
|
|
501
|
+
}
|
|
502
|
+
globWithOptions(patterns, ...options) {
|
|
503
|
+
const globFn = this.globFunction || pm$1;
|
|
504
|
+
/* c8 ignore next 5 */
|
|
505
|
+
if (!globFn) throw new Error("Please specify a glob function to use glob matching.");
|
|
506
|
+
var isMatch = this.globCache[patterns.join("\0")];
|
|
507
|
+
if (!isMatch) {
|
|
508
|
+
isMatch = globFn(patterns, ...options);
|
|
509
|
+
this.globCache[patterns.join("\0")] = isMatch;
|
|
503
510
|
}
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
511
|
+
this.options.filters.push((path$2) => isMatch(path$2));
|
|
512
|
+
return this;
|
|
513
|
+
}
|
|
514
|
+
};
|
|
508
515
|
|
|
509
516
|
//#endregion
|
|
510
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/
|
|
511
|
-
var
|
|
512
|
-
const
|
|
513
|
-
const
|
|
517
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/constants.js
|
|
518
|
+
var require_constants = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
519
|
+
const WIN_SLASH = "\\\\/";
|
|
520
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
514
521
|
/**
|
|
515
|
-
*
|
|
522
|
+
* Posix glob regex
|
|
516
523
|
*/
|
|
517
|
-
const
|
|
524
|
+
const DOT_LITERAL = "\\.";
|
|
525
|
+
const PLUS_LITERAL = "\\+";
|
|
526
|
+
const QMARK_LITERAL = "\\?";
|
|
527
|
+
const SLASH_LITERAL = "\\/";
|
|
528
|
+
const ONE_CHAR = "(?=.)";
|
|
529
|
+
const QMARK = "[^/]";
|
|
530
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
531
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
532
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
533
|
+
const POSIX_CHARS = {
|
|
534
|
+
DOT_LITERAL,
|
|
535
|
+
PLUS_LITERAL,
|
|
536
|
+
QMARK_LITERAL,
|
|
537
|
+
SLASH_LITERAL,
|
|
538
|
+
ONE_CHAR,
|
|
539
|
+
QMARK,
|
|
540
|
+
END_ANCHOR,
|
|
541
|
+
DOTS_SLASH,
|
|
542
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
543
|
+
NO_DOTS: `(?!${START_ANCHOR}${DOTS_SLASH})`,
|
|
544
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`,
|
|
545
|
+
NO_DOTS_SLASH: `(?!${DOTS_SLASH})`,
|
|
546
|
+
QMARK_NO_DOT: `[^.${SLASH_LITERAL}]`,
|
|
547
|
+
STAR: `${QMARK}*?`,
|
|
548
|
+
START_ANCHOR,
|
|
549
|
+
SEP: "/"
|
|
550
|
+
};
|
|
518
551
|
/**
|
|
519
|
-
*
|
|
552
|
+
* Windows glob regex
|
|
520
553
|
*/
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
}
|
|
530
|
-
|
|
554
|
+
const WINDOWS_CHARS = {
|
|
555
|
+
...POSIX_CHARS,
|
|
556
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
557
|
+
QMARK: WIN_NO_SLASH,
|
|
558
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
559
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
560
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
561
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
562
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
563
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
564
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
565
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
566
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
567
|
+
SEP: "\\"
|
|
531
568
|
};
|
|
532
569
|
/**
|
|
533
|
-
*
|
|
570
|
+
* POSIX Bracket Regex
|
|
534
571
|
*/
|
|
535
|
-
const
|
|
536
|
-
|
|
572
|
+
const POSIX_REGEX_SOURCE = {
|
|
573
|
+
alnum: "a-zA-Z0-9",
|
|
574
|
+
alpha: "a-zA-Z",
|
|
575
|
+
ascii: "\\x00-\\x7F",
|
|
576
|
+
blank: " \\t",
|
|
577
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
578
|
+
digit: "0-9",
|
|
579
|
+
graph: "\\x21-\\x7E",
|
|
580
|
+
lower: "a-z",
|
|
581
|
+
print: "\\x20-\\x7E ",
|
|
582
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
583
|
+
space: " \\t\\r\\n\\v\\f",
|
|
584
|
+
upper: "A-Z",
|
|
585
|
+
word: "A-Za-z0-9_",
|
|
586
|
+
xdigit: "A-Fa-f0-9"
|
|
587
|
+
};
|
|
588
|
+
module.exports = {
|
|
589
|
+
MAX_LENGTH: 1024 * 64,
|
|
590
|
+
POSIX_REGEX_SOURCE,
|
|
591
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
592
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
593
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
594
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
595
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
596
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
597
|
+
REPLACEMENTS: {
|
|
598
|
+
__proto__: null,
|
|
599
|
+
"***": "*",
|
|
600
|
+
"**/**": "**",
|
|
601
|
+
"**/**/**": "**"
|
|
602
|
+
},
|
|
603
|
+
CHAR_0: 48,
|
|
604
|
+
CHAR_9: 57,
|
|
605
|
+
CHAR_UPPERCASE_A: 65,
|
|
606
|
+
CHAR_LOWERCASE_A: 97,
|
|
607
|
+
CHAR_UPPERCASE_Z: 90,
|
|
608
|
+
CHAR_LOWERCASE_Z: 122,
|
|
609
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
610
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
611
|
+
CHAR_ASTERISK: 42,
|
|
612
|
+
CHAR_AMPERSAND: 38,
|
|
613
|
+
CHAR_AT: 64,
|
|
614
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
615
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
616
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
617
|
+
CHAR_COLON: 58,
|
|
618
|
+
CHAR_COMMA: 44,
|
|
619
|
+
CHAR_DOT: 46,
|
|
620
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
621
|
+
CHAR_EQUAL: 61,
|
|
622
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
623
|
+
CHAR_FORM_FEED: 12,
|
|
624
|
+
CHAR_FORWARD_SLASH: 47,
|
|
625
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
626
|
+
CHAR_HASH: 35,
|
|
627
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
628
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
629
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
630
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
631
|
+
CHAR_LINE_FEED: 10,
|
|
632
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
633
|
+
CHAR_PERCENT: 37,
|
|
634
|
+
CHAR_PLUS: 43,
|
|
635
|
+
CHAR_QUESTION_MARK: 63,
|
|
636
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
637
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
638
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
639
|
+
CHAR_SEMICOLON: 59,
|
|
640
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
641
|
+
CHAR_SPACE: 32,
|
|
642
|
+
CHAR_TAB: 9,
|
|
643
|
+
CHAR_UNDERSCORE: 95,
|
|
644
|
+
CHAR_VERTICAL_LINE: 124,
|
|
645
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
646
|
+
extglobChars(chars) {
|
|
647
|
+
return {
|
|
648
|
+
"!": {
|
|
649
|
+
type: "negate",
|
|
650
|
+
open: "(?:(?!(?:",
|
|
651
|
+
close: `))${chars.STAR})`
|
|
652
|
+
},
|
|
653
|
+
"?": {
|
|
654
|
+
type: "qmark",
|
|
655
|
+
open: "(?:",
|
|
656
|
+
close: ")?"
|
|
657
|
+
},
|
|
658
|
+
"+": {
|
|
659
|
+
type: "plus",
|
|
660
|
+
open: "(?:",
|
|
661
|
+
close: ")+"
|
|
662
|
+
},
|
|
663
|
+
"*": {
|
|
664
|
+
type: "star",
|
|
665
|
+
open: "(?:",
|
|
666
|
+
close: ")*"
|
|
667
|
+
},
|
|
668
|
+
"@": {
|
|
669
|
+
type: "at",
|
|
670
|
+
open: "(?:",
|
|
671
|
+
close: ")"
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
},
|
|
675
|
+
globChars(win32$1) {
|
|
676
|
+
return win32$1 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
677
|
+
}
|
|
678
|
+
};
|
|
679
|
+
}));
|
|
680
|
+
|
|
681
|
+
//#endregion
|
|
682
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/utils.js
|
|
683
|
+
var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
684
|
+
const { REGEX_BACKSLASH, REGEX_REMOVE_BACKSLASH, REGEX_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_GLOBAL } = require_constants();
|
|
685
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
686
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
687
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
688
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
689
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
690
|
+
exports.isWindows = () => {
|
|
691
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
692
|
+
const platform = navigator.platform.toLowerCase();
|
|
693
|
+
return platform === "win32" || platform === "windows";
|
|
694
|
+
}
|
|
695
|
+
if (typeof process !== "undefined" && process.platform) return process.platform === "win32";
|
|
696
|
+
return false;
|
|
697
|
+
};
|
|
698
|
+
exports.removeBackslashes = (str) => {
|
|
699
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
700
|
+
return match === "\\" ? "" : match;
|
|
701
|
+
});
|
|
702
|
+
};
|
|
703
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
704
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
705
|
+
if (idx === -1) return input;
|
|
706
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
707
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
708
|
+
};
|
|
709
|
+
exports.removePrefix = (input, state = {}) => {
|
|
710
|
+
let output = input;
|
|
711
|
+
if (output.startsWith("./")) {
|
|
712
|
+
output = output.slice(2);
|
|
713
|
+
state.prefix = "./";
|
|
714
|
+
}
|
|
715
|
+
return output;
|
|
716
|
+
};
|
|
717
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
718
|
+
let output = `${options.contains ? "" : "^"}(?:${input})${options.contains ? "" : "$"}`;
|
|
719
|
+
if (state.negated === true) output = `(?:^(?!${output}).*$)`;
|
|
720
|
+
return output;
|
|
721
|
+
};
|
|
722
|
+
exports.basename = (path$2, { windows } = {}) => {
|
|
723
|
+
const segs = path$2.split(windows ? /[\\/]/ : "/");
|
|
724
|
+
const last = segs[segs.length - 1];
|
|
725
|
+
if (last === "") return segs[segs.length - 2];
|
|
726
|
+
return last;
|
|
727
|
+
};
|
|
728
|
+
}));
|
|
729
|
+
|
|
730
|
+
//#endregion
|
|
731
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/scan.js
|
|
732
|
+
var require_scan = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
733
|
+
const utils = require_utils();
|
|
734
|
+
const { CHAR_ASTERISK, CHAR_AT, CHAR_BACKWARD_SLASH, CHAR_COMMA, CHAR_DOT, CHAR_EXCLAMATION_MARK, CHAR_FORWARD_SLASH, CHAR_LEFT_CURLY_BRACE, CHAR_LEFT_PARENTHESES, CHAR_LEFT_SQUARE_BRACKET, CHAR_PLUS, CHAR_QUESTION_MARK, CHAR_RIGHT_CURLY_BRACE, CHAR_RIGHT_PARENTHESES, CHAR_RIGHT_SQUARE_BRACKET } = require_constants();
|
|
735
|
+
const isPathSeparator = (code) => {
|
|
736
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
737
|
+
};
|
|
738
|
+
const depth = (token) => {
|
|
739
|
+
if (token.isPrefix !== true) token.depth = token.isGlobstar ? Infinity : 1;
|
|
537
740
|
};
|
|
538
741
|
/**
|
|
539
|
-
*
|
|
540
|
-
*
|
|
541
|
-
*
|
|
542
|
-
*
|
|
742
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
743
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
744
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
745
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
746
|
+
*
|
|
747
|
+
* ```js
|
|
748
|
+
* const pm = require('picomatch');
|
|
749
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
750
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
751
|
+
* ```
|
|
752
|
+
* @param {String} `str`
|
|
753
|
+
* @param {Object} `options`
|
|
754
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
755
|
+
* @api public
|
|
543
756
|
*/
|
|
544
|
-
const
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
const
|
|
548
|
-
const
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
757
|
+
const scan = (input, options) => {
|
|
758
|
+
const opts = options || {};
|
|
759
|
+
const length = input.length - 1;
|
|
760
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
761
|
+
const slashes = [];
|
|
762
|
+
const tokens = [];
|
|
763
|
+
const parts = [];
|
|
764
|
+
let str = input;
|
|
765
|
+
let index = -1;
|
|
766
|
+
let start = 0;
|
|
767
|
+
let lastIndex = 0;
|
|
768
|
+
let isBrace = false;
|
|
769
|
+
let isBracket = false;
|
|
770
|
+
let isGlob = false;
|
|
771
|
+
let isExtglob = false;
|
|
772
|
+
let isGlobstar = false;
|
|
773
|
+
let braceEscaped = false;
|
|
774
|
+
let backslashes = false;
|
|
775
|
+
let negated = false;
|
|
776
|
+
let negatedExtglob = false;
|
|
777
|
+
let finished = false;
|
|
778
|
+
let braces = 0;
|
|
779
|
+
let prev;
|
|
780
|
+
let code;
|
|
781
|
+
let token = {
|
|
553
782
|
value: "",
|
|
554
|
-
|
|
783
|
+
depth: 0,
|
|
784
|
+
isGlob: false
|
|
555
785
|
};
|
|
556
|
-
const
|
|
557
|
-
const
|
|
558
|
-
const
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
const globstar = (opts$1) => {
|
|
562
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
563
|
-
};
|
|
564
|
-
const nodot = opts.dot ? "" : NO_DOT;
|
|
565
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
566
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
567
|
-
if (opts.capture) star = `(${star})`;
|
|
568
|
-
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
569
|
-
const state = {
|
|
570
|
-
input,
|
|
571
|
-
index: -1,
|
|
572
|
-
start: 0,
|
|
573
|
-
dot: opts.dot === true,
|
|
574
|
-
consumed: "",
|
|
575
|
-
output: "",
|
|
576
|
-
prefix: "",
|
|
577
|
-
backtrack: false,
|
|
578
|
-
negated: false,
|
|
579
|
-
brackets: 0,
|
|
580
|
-
braces: 0,
|
|
581
|
-
parens: 0,
|
|
582
|
-
quotes: 0,
|
|
583
|
-
globstar: false,
|
|
584
|
-
tokens
|
|
585
|
-
};
|
|
586
|
-
input = utils.removePrefix(input, state);
|
|
587
|
-
len = input.length;
|
|
588
|
-
const extglobs = [];
|
|
589
|
-
const braces = [];
|
|
590
|
-
const stack = [];
|
|
591
|
-
let prev = bos;
|
|
592
|
-
let value;
|
|
593
|
-
/**
|
|
594
|
-
* Tokenizing helpers
|
|
595
|
-
*/
|
|
596
|
-
const eos = () => state.index === len - 1;
|
|
597
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
598
|
-
const advance = state.advance = () => input[++state.index] || "";
|
|
599
|
-
const remaining = () => input.slice(state.index + 1);
|
|
600
|
-
const consume = (value$1 = "", num = 0) => {
|
|
601
|
-
state.consumed += value$1;
|
|
602
|
-
state.index += num;
|
|
603
|
-
};
|
|
604
|
-
const append = (token) => {
|
|
605
|
-
state.output += token.output != null ? token.output : token.value;
|
|
606
|
-
consume(token.value);
|
|
786
|
+
const eos = () => index >= length;
|
|
787
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
788
|
+
const advance = () => {
|
|
789
|
+
prev = code;
|
|
790
|
+
return str.charCodeAt(++index);
|
|
607
791
|
};
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
792
|
+
while (index < length) {
|
|
793
|
+
code = advance();
|
|
794
|
+
let next;
|
|
795
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
796
|
+
backslashes = token.backslashes = true;
|
|
797
|
+
code = advance();
|
|
798
|
+
if (code === CHAR_LEFT_CURLY_BRACE) braceEscaped = true;
|
|
799
|
+
continue;
|
|
614
800
|
}
|
|
615
|
-
if (
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
801
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
802
|
+
braces++;
|
|
803
|
+
while (eos() !== true && (code = advance())) {
|
|
804
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
805
|
+
backslashes = token.backslashes = true;
|
|
806
|
+
advance();
|
|
807
|
+
continue;
|
|
808
|
+
}
|
|
809
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
810
|
+
braces++;
|
|
811
|
+
continue;
|
|
812
|
+
}
|
|
813
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
814
|
+
isBrace = token.isBrace = true;
|
|
815
|
+
isGlob = token.isGlob = true;
|
|
816
|
+
finished = true;
|
|
817
|
+
if (scanToEnd === true) continue;
|
|
818
|
+
break;
|
|
819
|
+
}
|
|
820
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
821
|
+
isBrace = token.isBrace = true;
|
|
822
|
+
isGlob = token.isGlob = true;
|
|
823
|
+
finished = true;
|
|
824
|
+
if (scanToEnd === true) continue;
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
828
|
+
braces--;
|
|
829
|
+
if (braces === 0) {
|
|
830
|
+
braceEscaped = false;
|
|
831
|
+
isBrace = token.isBrace = true;
|
|
832
|
+
finished = true;
|
|
833
|
+
break;
|
|
834
|
+
}
|
|
835
|
+
}
|
|
645
836
|
}
|
|
837
|
+
if (scanToEnd === true) continue;
|
|
838
|
+
break;
|
|
646
839
|
}
|
|
647
|
-
if (
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
const token = {
|
|
660
|
-
...EXTGLOB_CHARS[value$1],
|
|
661
|
-
conditions: 1,
|
|
662
|
-
inner: ""
|
|
663
|
-
};
|
|
664
|
-
token.prev = prev;
|
|
665
|
-
token.parens = state.parens;
|
|
666
|
-
token.output = state.output;
|
|
667
|
-
const output = (opts.capture ? "(" : "") + token.open;
|
|
668
|
-
increment("parens");
|
|
669
|
-
push({
|
|
670
|
-
type,
|
|
671
|
-
value: value$1,
|
|
672
|
-
output: state.output ? "" : ONE_CHAR
|
|
673
|
-
});
|
|
674
|
-
push({
|
|
675
|
-
type: "paren",
|
|
676
|
-
extglob: true,
|
|
677
|
-
value: advance(),
|
|
678
|
-
output
|
|
679
|
-
});
|
|
680
|
-
extglobs.push(token);
|
|
681
|
-
};
|
|
682
|
-
const extglobClose = (token) => {
|
|
683
|
-
let output = token.close + (opts.capture ? ")" : "");
|
|
684
|
-
let rest;
|
|
685
|
-
if (token.type === "negate") {
|
|
686
|
-
let extglobStar = star;
|
|
687
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
688
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
689
|
-
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
690
|
-
...options,
|
|
691
|
-
fastpaths: false
|
|
692
|
-
}).output})${extglobStar})`;
|
|
693
|
-
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
694
|
-
}
|
|
695
|
-
push({
|
|
696
|
-
type: "paren",
|
|
697
|
-
extglob: true,
|
|
698
|
-
value,
|
|
699
|
-
output
|
|
700
|
-
});
|
|
701
|
-
decrement("parens");
|
|
702
|
-
};
|
|
703
|
-
/**
|
|
704
|
-
* Fast paths
|
|
705
|
-
*/
|
|
706
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
707
|
-
let backslashes = false;
|
|
708
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
709
|
-
if (first === "\\") {
|
|
710
|
-
backslashes = true;
|
|
711
|
-
return m;
|
|
712
|
-
}
|
|
713
|
-
if (first === "?") {
|
|
714
|
-
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
715
|
-
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
716
|
-
return QMARK.repeat(chars.length);
|
|
840
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
841
|
+
slashes.push(index);
|
|
842
|
+
tokens.push(token);
|
|
843
|
+
token = {
|
|
844
|
+
value: "",
|
|
845
|
+
depth: 0,
|
|
846
|
+
isGlob: false
|
|
847
|
+
};
|
|
848
|
+
if (finished === true) continue;
|
|
849
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
850
|
+
start += 2;
|
|
851
|
+
continue;
|
|
717
852
|
}
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
853
|
+
lastIndex = index + 1;
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
if (opts.noext !== true) {
|
|
857
|
+
if ((code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK) === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
858
|
+
isGlob = token.isGlob = true;
|
|
859
|
+
isExtglob = token.isExtglob = true;
|
|
860
|
+
finished = true;
|
|
861
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) negatedExtglob = true;
|
|
862
|
+
if (scanToEnd === true) {
|
|
863
|
+
while (eos() !== true && (code = advance())) {
|
|
864
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
865
|
+
backslashes = token.backslashes = true;
|
|
866
|
+
code = advance();
|
|
867
|
+
continue;
|
|
868
|
+
}
|
|
869
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
870
|
+
isGlob = token.isGlob = true;
|
|
871
|
+
finished = true;
|
|
872
|
+
break;
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
continue;
|
|
876
|
+
}
|
|
877
|
+
break;
|
|
722
878
|
}
|
|
723
|
-
return esc ? m : `\\${m}`;
|
|
724
|
-
});
|
|
725
|
-
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
726
|
-
else output = output.replace(/\\+/g, (m) => {
|
|
727
|
-
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
728
|
-
});
|
|
729
|
-
if (output === input && opts.contains === true) {
|
|
730
|
-
state.output = input;
|
|
731
|
-
return state;
|
|
732
879
|
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
while (!eos()) {
|
|
740
|
-
value = advance();
|
|
741
|
-
if (value === "\0") continue;
|
|
742
|
-
/**
|
|
743
|
-
* Escaped characters
|
|
744
|
-
*/
|
|
745
|
-
if (value === "\\") {
|
|
746
|
-
const next = peek();
|
|
747
|
-
if (next === "/" && opts.bash !== true) continue;
|
|
748
|
-
if (next === "." || next === ";") continue;
|
|
749
|
-
if (!next) {
|
|
750
|
-
value += "\\";
|
|
751
|
-
push({
|
|
752
|
-
type: "text",
|
|
753
|
-
value
|
|
754
|
-
});
|
|
755
|
-
continue;
|
|
756
|
-
}
|
|
757
|
-
const match = /^\\+/.exec(remaining());
|
|
758
|
-
let slashes = 0;
|
|
759
|
-
if (match && match[0].length > 2) {
|
|
760
|
-
slashes = match[0].length;
|
|
761
|
-
state.index += slashes;
|
|
762
|
-
if (slashes % 2 !== 0) value += "\\";
|
|
763
|
-
}
|
|
764
|
-
if (opts.unescape === true) value = advance();
|
|
765
|
-
else value += advance();
|
|
766
|
-
if (state.brackets === 0) {
|
|
767
|
-
push({
|
|
768
|
-
type: "text",
|
|
769
|
-
value
|
|
770
|
-
});
|
|
771
|
-
continue;
|
|
772
|
-
}
|
|
880
|
+
if (code === CHAR_ASTERISK) {
|
|
881
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
882
|
+
isGlob = token.isGlob = true;
|
|
883
|
+
finished = true;
|
|
884
|
+
if (scanToEnd === true) continue;
|
|
885
|
+
break;
|
|
773
886
|
}
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
continue;
|
|
793
|
-
}
|
|
794
|
-
}
|
|
887
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
888
|
+
isGlob = token.isGlob = true;
|
|
889
|
+
finished = true;
|
|
890
|
+
if (scanToEnd === true) continue;
|
|
891
|
+
break;
|
|
892
|
+
}
|
|
893
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
894
|
+
while (eos() !== true && (next = advance())) {
|
|
895
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
896
|
+
backslashes = token.backslashes = true;
|
|
897
|
+
advance();
|
|
898
|
+
continue;
|
|
899
|
+
}
|
|
900
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
901
|
+
isBracket = token.isBracket = true;
|
|
902
|
+
isGlob = token.isGlob = true;
|
|
903
|
+
finished = true;
|
|
904
|
+
break;
|
|
795
905
|
}
|
|
796
906
|
}
|
|
797
|
-
if (
|
|
798
|
-
|
|
799
|
-
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
800
|
-
prev.value += value;
|
|
801
|
-
append({ value });
|
|
802
|
-
continue;
|
|
803
|
-
}
|
|
804
|
-
/**
|
|
805
|
-
* If we're inside a quoted string, continue
|
|
806
|
-
* until we reach the closing double quote.
|
|
807
|
-
*/
|
|
808
|
-
if (state.quotes === 1 && value !== "\"") {
|
|
809
|
-
value = utils.escapeRegex(value);
|
|
810
|
-
prev.value += value;
|
|
811
|
-
append({ value });
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
/**
|
|
815
|
-
* Double quotes
|
|
816
|
-
*/
|
|
817
|
-
if (value === "\"") {
|
|
818
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
819
|
-
if (opts.keepQuotes === true) push({
|
|
820
|
-
type: "text",
|
|
821
|
-
value
|
|
822
|
-
});
|
|
823
|
-
continue;
|
|
907
|
+
if (scanToEnd === true) continue;
|
|
908
|
+
break;
|
|
824
909
|
}
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
if (value === "(") {
|
|
829
|
-
increment("parens");
|
|
830
|
-
push({
|
|
831
|
-
type: "paren",
|
|
832
|
-
value
|
|
833
|
-
});
|
|
910
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
911
|
+
negated = token.negated = true;
|
|
912
|
+
start++;
|
|
834
913
|
continue;
|
|
835
914
|
}
|
|
836
|
-
if (
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
915
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
916
|
+
isGlob = token.isGlob = true;
|
|
917
|
+
if (scanToEnd === true) {
|
|
918
|
+
while (eos() !== true && (code = advance())) {
|
|
919
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
920
|
+
backslashes = token.backslashes = true;
|
|
921
|
+
code = advance();
|
|
922
|
+
continue;
|
|
923
|
+
}
|
|
924
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
925
|
+
finished = true;
|
|
926
|
+
break;
|
|
927
|
+
}
|
|
928
|
+
}
|
|
841
929
|
continue;
|
|
842
930
|
}
|
|
843
|
-
|
|
844
|
-
type: "paren",
|
|
845
|
-
value,
|
|
846
|
-
output: state.parens ? ")" : "\\)"
|
|
847
|
-
});
|
|
848
|
-
decrement("parens");
|
|
849
|
-
continue;
|
|
931
|
+
break;
|
|
850
932
|
}
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
856
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
857
|
-
value = `\\${value}`;
|
|
858
|
-
} else increment("brackets");
|
|
859
|
-
push({
|
|
860
|
-
type: "bracket",
|
|
861
|
-
value
|
|
862
|
-
});
|
|
863
|
-
continue;
|
|
933
|
+
if (isGlob === true) {
|
|
934
|
+
finished = true;
|
|
935
|
+
if (scanToEnd === true) continue;
|
|
936
|
+
break;
|
|
864
937
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
938
|
+
}
|
|
939
|
+
if (opts.noext === true) {
|
|
940
|
+
isExtglob = false;
|
|
941
|
+
isGlob = false;
|
|
942
|
+
}
|
|
943
|
+
let base = str;
|
|
944
|
+
let prefix = "";
|
|
945
|
+
let glob = "";
|
|
946
|
+
if (start > 0) {
|
|
947
|
+
prefix = str.slice(0, start);
|
|
948
|
+
str = str.slice(start);
|
|
949
|
+
lastIndex -= start;
|
|
950
|
+
}
|
|
951
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
952
|
+
base = str.slice(0, lastIndex);
|
|
953
|
+
glob = str.slice(lastIndex);
|
|
954
|
+
} else if (isGlob === true) {
|
|
955
|
+
base = "";
|
|
956
|
+
glob = str;
|
|
957
|
+
} else base = str;
|
|
958
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
959
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) base = base.slice(0, -1);
|
|
960
|
+
}
|
|
961
|
+
if (opts.unescape === true) {
|
|
962
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
963
|
+
if (base && backslashes === true) base = utils.removeBackslashes(base);
|
|
964
|
+
}
|
|
965
|
+
const state = {
|
|
966
|
+
prefix,
|
|
967
|
+
input,
|
|
968
|
+
start,
|
|
969
|
+
base,
|
|
970
|
+
glob,
|
|
971
|
+
isBrace,
|
|
972
|
+
isBracket,
|
|
973
|
+
isGlob,
|
|
974
|
+
isExtglob,
|
|
975
|
+
isGlobstar,
|
|
976
|
+
negated,
|
|
977
|
+
negatedExtglob
|
|
978
|
+
};
|
|
979
|
+
if (opts.tokens === true) {
|
|
980
|
+
state.maxDepth = 0;
|
|
981
|
+
if (!isPathSeparator(code)) tokens.push(token);
|
|
982
|
+
state.tokens = tokens;
|
|
983
|
+
}
|
|
984
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
985
|
+
let prevIndex;
|
|
986
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
987
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
988
|
+
const i = slashes[idx];
|
|
989
|
+
const value = input.slice(n, i);
|
|
990
|
+
if (opts.tokens) {
|
|
991
|
+
if (idx === 0 && start !== 0) {
|
|
992
|
+
tokens[idx].isPrefix = true;
|
|
993
|
+
tokens[idx].value = prefix;
|
|
994
|
+
} else tokens[idx].value = value;
|
|
995
|
+
depth(tokens[idx]);
|
|
996
|
+
state.maxDepth += tokens[idx].depth;
|
|
873
997
|
}
|
|
874
|
-
if (
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
998
|
+
if (idx !== 0 || value !== "") parts.push(value);
|
|
999
|
+
prevIndex = i;
|
|
1000
|
+
}
|
|
1001
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1002
|
+
const value = input.slice(prevIndex + 1);
|
|
1003
|
+
parts.push(value);
|
|
1004
|
+
if (opts.tokens) {
|
|
1005
|
+
tokens[tokens.length - 1].value = value;
|
|
1006
|
+
depth(tokens[tokens.length - 1]);
|
|
1007
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
882
1008
|
}
|
|
883
|
-
decrement("brackets");
|
|
884
|
-
const prevValue = prev.value.slice(1);
|
|
885
|
-
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
886
|
-
prev.value += value;
|
|
887
|
-
append({ value });
|
|
888
|
-
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
889
|
-
const escaped = utils.escapeRegex(prev.value);
|
|
890
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
891
|
-
if (opts.literalBrackets === true) {
|
|
892
|
-
state.output += escaped;
|
|
893
|
-
prev.value = escaped;
|
|
894
|
-
continue;
|
|
895
|
-
}
|
|
896
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
897
|
-
state.output += prev.value;
|
|
898
|
-
continue;
|
|
899
1009
|
}
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
1010
|
+
state.slashes = slashes;
|
|
1011
|
+
state.parts = parts;
|
|
1012
|
+
}
|
|
1013
|
+
return state;
|
|
1014
|
+
};
|
|
1015
|
+
module.exports = scan;
|
|
1016
|
+
}));
|
|
1017
|
+
|
|
1018
|
+
//#endregion
|
|
1019
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/parse.js
|
|
1020
|
+
var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1021
|
+
const constants = require_constants();
|
|
1022
|
+
const utils = require_utils();
|
|
1023
|
+
/**
|
|
1024
|
+
* Constants
|
|
1025
|
+
*/
|
|
1026
|
+
const { MAX_LENGTH, POSIX_REGEX_SOURCE, REGEX_NON_SPECIAL_CHARS, REGEX_SPECIAL_CHARS_BACKREF, REPLACEMENTS } = constants;
|
|
1027
|
+
/**
|
|
1028
|
+
* Helpers
|
|
1029
|
+
*/
|
|
1030
|
+
const expandRange = (args, options) => {
|
|
1031
|
+
if (typeof options.expandRange === "function") return options.expandRange(...args, options);
|
|
1032
|
+
args.sort();
|
|
1033
|
+
const value = `[${args.join("-")}]`;
|
|
1034
|
+
try {
|
|
1035
|
+
new RegExp(value);
|
|
1036
|
+
} catch (ex) {
|
|
1037
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
1038
|
+
}
|
|
1039
|
+
return value;
|
|
1040
|
+
};
|
|
1041
|
+
/**
|
|
1042
|
+
* Create the message for a syntax error
|
|
1043
|
+
*/
|
|
1044
|
+
const syntaxError = (type, char) => {
|
|
1045
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1046
|
+
};
|
|
1047
|
+
/**
|
|
1048
|
+
* Parse the given input string.
|
|
1049
|
+
* @param {String} input
|
|
1050
|
+
* @param {Object} options
|
|
1051
|
+
* @return {Object}
|
|
1052
|
+
*/
|
|
1053
|
+
const parse = (input, options) => {
|
|
1054
|
+
if (typeof input !== "string") throw new TypeError("Expected a string");
|
|
1055
|
+
input = REPLACEMENTS[input] || input;
|
|
1056
|
+
const opts = { ...options };
|
|
1057
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1058
|
+
let len = input.length;
|
|
1059
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1060
|
+
const bos = {
|
|
1061
|
+
type: "bos",
|
|
1062
|
+
value: "",
|
|
1063
|
+
output: opts.prepend || ""
|
|
1064
|
+
};
|
|
1065
|
+
const tokens = [bos];
|
|
1066
|
+
const capture = opts.capture ? "" : "?:";
|
|
1067
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
1068
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
1069
|
+
const { DOT_LITERAL, PLUS_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOT_SLASH, NO_DOTS_SLASH, QMARK, QMARK_NO_DOT, STAR, START_ANCHOR } = PLATFORM_CHARS;
|
|
1070
|
+
const globstar = (opts$1) => {
|
|
1071
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1072
|
+
};
|
|
1073
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
1074
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1075
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1076
|
+
if (opts.capture) star = `(${star})`;
|
|
1077
|
+
if (typeof opts.noext === "boolean") opts.noextglob = opts.noext;
|
|
1078
|
+
const state = {
|
|
1079
|
+
input,
|
|
1080
|
+
index: -1,
|
|
1081
|
+
start: 0,
|
|
1082
|
+
dot: opts.dot === true,
|
|
1083
|
+
consumed: "",
|
|
1084
|
+
output: "",
|
|
1085
|
+
prefix: "",
|
|
1086
|
+
backtrack: false,
|
|
1087
|
+
negated: false,
|
|
1088
|
+
brackets: 0,
|
|
1089
|
+
braces: 0,
|
|
1090
|
+
parens: 0,
|
|
1091
|
+
quotes: 0,
|
|
1092
|
+
globstar: false,
|
|
1093
|
+
tokens
|
|
1094
|
+
};
|
|
1095
|
+
input = utils.removePrefix(input, state);
|
|
1096
|
+
len = input.length;
|
|
1097
|
+
const extglobs = [];
|
|
1098
|
+
const braces = [];
|
|
1099
|
+
const stack = [];
|
|
1100
|
+
let prev = bos;
|
|
1101
|
+
let value;
|
|
1102
|
+
/**
|
|
1103
|
+
* Tokenizing helpers
|
|
1104
|
+
*/
|
|
1105
|
+
const eos = () => state.index === len - 1;
|
|
1106
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1107
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
1108
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1109
|
+
const consume = (value$1 = "", num = 0) => {
|
|
1110
|
+
state.consumed += value$1;
|
|
1111
|
+
state.index += num;
|
|
1112
|
+
};
|
|
1113
|
+
const append = (token) => {
|
|
1114
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1115
|
+
consume(token.value);
|
|
1116
|
+
};
|
|
1117
|
+
const negate = () => {
|
|
1118
|
+
let count = 1;
|
|
1119
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
1120
|
+
advance();
|
|
1121
|
+
state.start++;
|
|
1122
|
+
count++;
|
|
915
1123
|
}
|
|
916
|
-
if (
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1124
|
+
if (count % 2 === 0) return false;
|
|
1125
|
+
state.negated = true;
|
|
1126
|
+
state.start++;
|
|
1127
|
+
return true;
|
|
1128
|
+
};
|
|
1129
|
+
const increment = (type) => {
|
|
1130
|
+
state[type]++;
|
|
1131
|
+
stack.push(type);
|
|
1132
|
+
};
|
|
1133
|
+
const decrement = (type) => {
|
|
1134
|
+
state[type]--;
|
|
1135
|
+
stack.pop();
|
|
1136
|
+
};
|
|
1137
|
+
/**
|
|
1138
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
1139
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
1140
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
1141
|
+
* characters are plain text. This improves performance and simplifies
|
|
1142
|
+
* lookbehinds.
|
|
1143
|
+
*/
|
|
1144
|
+
const push = (tok) => {
|
|
1145
|
+
if (prev.type === "globstar") {
|
|
1146
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
1147
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
1148
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
1149
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1150
|
+
prev.type = "star";
|
|
1151
|
+
prev.value = "*";
|
|
1152
|
+
prev.output = star;
|
|
1153
|
+
state.output += prev.output;
|
|
945
1154
|
}
|
|
946
|
-
push({
|
|
947
|
-
type: "brace",
|
|
948
|
-
value,
|
|
949
|
-
output
|
|
950
|
-
});
|
|
951
|
-
decrement("braces");
|
|
952
|
-
braces.pop();
|
|
953
|
-
continue;
|
|
954
|
-
}
|
|
955
|
-
/**
|
|
956
|
-
* Pipes
|
|
957
|
-
*/
|
|
958
|
-
if (value === "|") {
|
|
959
|
-
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
960
|
-
push({
|
|
961
|
-
type: "text",
|
|
962
|
-
value
|
|
963
|
-
});
|
|
964
|
-
continue;
|
|
965
1155
|
}
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
if (brace && stack[stack.length - 1] === "braces") {
|
|
973
|
-
brace.comma = true;
|
|
974
|
-
output = "|";
|
|
975
|
-
}
|
|
976
|
-
push({
|
|
977
|
-
type: "comma",
|
|
978
|
-
value,
|
|
979
|
-
output
|
|
980
|
-
});
|
|
981
|
-
continue;
|
|
1156
|
+
if (extglobs.length && tok.type !== "paren") extglobs[extglobs.length - 1].inner += tok.value;
|
|
1157
|
+
if (tok.value || tok.output) append(tok);
|
|
1158
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1159
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
1160
|
+
prev.value += tok.value;
|
|
1161
|
+
return;
|
|
982
1162
|
}
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1163
|
+
tok.prev = prev;
|
|
1164
|
+
tokens.push(tok);
|
|
1165
|
+
prev = tok;
|
|
1166
|
+
};
|
|
1167
|
+
const extglobOpen = (type, value$1) => {
|
|
1168
|
+
const token = {
|
|
1169
|
+
...EXTGLOB_CHARS[value$1],
|
|
1170
|
+
conditions: 1,
|
|
1171
|
+
inner: ""
|
|
1172
|
+
};
|
|
1173
|
+
token.prev = prev;
|
|
1174
|
+
token.parens = state.parens;
|
|
1175
|
+
token.output = state.output;
|
|
1176
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1177
|
+
increment("parens");
|
|
1178
|
+
push({
|
|
1179
|
+
type,
|
|
1180
|
+
value: value$1,
|
|
1181
|
+
output: state.output ? "" : ONE_CHAR
|
|
1182
|
+
});
|
|
1183
|
+
push({
|
|
1184
|
+
type: "paren",
|
|
1185
|
+
extglob: true,
|
|
1186
|
+
value: advance(),
|
|
1187
|
+
output
|
|
1188
|
+
});
|
|
1189
|
+
extglobs.push(token);
|
|
1190
|
+
};
|
|
1191
|
+
const extglobClose = (token) => {
|
|
1192
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1193
|
+
let rest;
|
|
1194
|
+
if (token.type === "negate") {
|
|
1195
|
+
let extglobStar = star;
|
|
1196
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) extglobStar = globstar(opts);
|
|
1197
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) output = token.close = `)$))${extglobStar}`;
|
|
1198
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) output = token.close = `)${parse(rest, {
|
|
1199
|
+
...options,
|
|
1200
|
+
fastpaths: false
|
|
1201
|
+
}).output})${extglobStar})`;
|
|
1202
|
+
if (token.prev.type === "bos") state.negatedExtglob = true;
|
|
1001
1203
|
}
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1204
|
+
push({
|
|
1205
|
+
type: "paren",
|
|
1206
|
+
extglob: true,
|
|
1207
|
+
value,
|
|
1208
|
+
output
|
|
1209
|
+
});
|
|
1210
|
+
decrement("parens");
|
|
1211
|
+
};
|
|
1212
|
+
/**
|
|
1213
|
+
* Fast paths
|
|
1214
|
+
*/
|
|
1215
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1216
|
+
let backslashes = false;
|
|
1217
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1218
|
+
if (first === "\\") {
|
|
1219
|
+
backslashes = true;
|
|
1220
|
+
return m;
|
|
1014
1221
|
}
|
|
1015
|
-
if (
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
output: DOT_LITERAL
|
|
1020
|
-
});
|
|
1021
|
-
continue;
|
|
1222
|
+
if (first === "?") {
|
|
1223
|
+
if (esc) return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1224
|
+
if (index === 0) return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1225
|
+
return QMARK.repeat(chars.length);
|
|
1022
1226
|
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1227
|
+
if (first === ".") return DOT_LITERAL.repeat(chars.length);
|
|
1228
|
+
if (first === "*") {
|
|
1229
|
+
if (esc) return esc + first + (rest ? star : "");
|
|
1230
|
+
return star;
|
|
1231
|
+
}
|
|
1232
|
+
return esc ? m : `\\${m}`;
|
|
1233
|
+
});
|
|
1234
|
+
if (backslashes === true) if (opts.unescape === true) output = output.replace(/\\/g, "");
|
|
1235
|
+
else output = output.replace(/\\+/g, (m) => {
|
|
1236
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1237
|
+
});
|
|
1238
|
+
if (output === input && opts.contains === true) {
|
|
1239
|
+
state.output = input;
|
|
1240
|
+
return state;
|
|
1029
1241
|
}
|
|
1242
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1243
|
+
return state;
|
|
1244
|
+
}
|
|
1245
|
+
/**
|
|
1246
|
+
* Tokenize input until we reach end-of-string
|
|
1247
|
+
*/
|
|
1248
|
+
while (!eos()) {
|
|
1249
|
+
value = advance();
|
|
1250
|
+
if (value === "\0") continue;
|
|
1030
1251
|
/**
|
|
1031
|
-
*
|
|
1252
|
+
* Escaped characters
|
|
1032
1253
|
*/
|
|
1033
|
-
if (value === "
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
const next = peek();
|
|
1040
|
-
let output = value;
|
|
1041
|
-
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1254
|
+
if (value === "\\") {
|
|
1255
|
+
const next = peek();
|
|
1256
|
+
if (next === "/" && opts.bash !== true) continue;
|
|
1257
|
+
if (next === "." || next === ";") continue;
|
|
1258
|
+
if (!next) {
|
|
1259
|
+
value += "\\";
|
|
1042
1260
|
push({
|
|
1043
1261
|
type: "text",
|
|
1044
|
-
value
|
|
1045
|
-
output
|
|
1262
|
+
value
|
|
1046
1263
|
});
|
|
1047
1264
|
continue;
|
|
1048
1265
|
}
|
|
1049
|
-
|
|
1266
|
+
const match = /^\\+/.exec(remaining());
|
|
1267
|
+
let slashes = 0;
|
|
1268
|
+
if (match && match[0].length > 2) {
|
|
1269
|
+
slashes = match[0].length;
|
|
1270
|
+
state.index += slashes;
|
|
1271
|
+
if (slashes % 2 !== 0) value += "\\";
|
|
1272
|
+
}
|
|
1273
|
+
if (opts.unescape === true) value = advance();
|
|
1274
|
+
else value += advance();
|
|
1275
|
+
if (state.brackets === 0) {
|
|
1050
1276
|
push({
|
|
1051
|
-
type: "
|
|
1052
|
-
value
|
|
1053
|
-
output: QMARK_NO_DOT
|
|
1277
|
+
type: "text",
|
|
1278
|
+
value
|
|
1054
1279
|
});
|
|
1055
1280
|
continue;
|
|
1056
1281
|
}
|
|
1057
|
-
push({
|
|
1058
|
-
type: "qmark",
|
|
1059
|
-
value,
|
|
1060
|
-
output: QMARK
|
|
1061
|
-
});
|
|
1062
|
-
continue;
|
|
1063
1282
|
}
|
|
1064
1283
|
/**
|
|
1065
|
-
*
|
|
1284
|
+
* If we're inside a regex character class, continue
|
|
1285
|
+
* until we reach the closing bracket.
|
|
1066
1286
|
*/
|
|
1067
|
-
if (value === "
|
|
1068
|
-
if (opts.
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1287
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1288
|
+
if (opts.posix !== false && value === ":") {
|
|
1289
|
+
const inner = prev.value.slice(1);
|
|
1290
|
+
if (inner.includes("[")) {
|
|
1291
|
+
prev.posix = true;
|
|
1292
|
+
if (inner.includes(":")) {
|
|
1293
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1294
|
+
const pre = prev.value.slice(0, idx);
|
|
1295
|
+
const posix$1 = POSIX_REGEX_SOURCE[prev.value.slice(idx + 2)];
|
|
1296
|
+
if (posix$1) {
|
|
1297
|
+
prev.value = pre + posix$1;
|
|
1298
|
+
state.backtrack = true;
|
|
1299
|
+
advance();
|
|
1300
|
+
if (!bos.output && tokens.indexOf(prev) === 1) bos.output = ONE_CHAR;
|
|
1301
|
+
continue;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1072
1304
|
}
|
|
1073
1305
|
}
|
|
1074
|
-
if (
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1306
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") value = `\\${value}`;
|
|
1307
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) value = `\\${value}`;
|
|
1308
|
+
if (opts.posix === true && value === "!" && prev.value === "[") value = "^";
|
|
1309
|
+
prev.value += value;
|
|
1310
|
+
append({ value });
|
|
1311
|
+
continue;
|
|
1078
1312
|
}
|
|
1079
1313
|
/**
|
|
1080
|
-
*
|
|
1314
|
+
* If we're inside a quoted string, continue
|
|
1315
|
+
* until we reach the closing double quote.
|
|
1081
1316
|
*/
|
|
1082
|
-
if (
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
}
|
|
1087
|
-
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1088
|
-
push({
|
|
1089
|
-
type: "plus",
|
|
1090
|
-
value,
|
|
1091
|
-
output: PLUS_LITERAL
|
|
1092
|
-
});
|
|
1093
|
-
continue;
|
|
1094
|
-
}
|
|
1095
|
-
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1096
|
-
push({
|
|
1097
|
-
type: "plus",
|
|
1098
|
-
value
|
|
1099
|
-
});
|
|
1100
|
-
continue;
|
|
1101
|
-
}
|
|
1102
|
-
push({
|
|
1103
|
-
type: "plus",
|
|
1104
|
-
value: PLUS_LITERAL
|
|
1105
|
-
});
|
|
1317
|
+
if (state.quotes === 1 && value !== "\"") {
|
|
1318
|
+
value = utils.escapeRegex(value);
|
|
1319
|
+
prev.value += value;
|
|
1320
|
+
append({ value });
|
|
1106
1321
|
continue;
|
|
1107
1322
|
}
|
|
1108
1323
|
/**
|
|
1109
|
-
*
|
|
1324
|
+
* Double quotes
|
|
1110
1325
|
*/
|
|
1111
|
-
if (value === "
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
type: "at",
|
|
1115
|
-
extglob: true,
|
|
1116
|
-
value,
|
|
1117
|
-
output: ""
|
|
1118
|
-
});
|
|
1119
|
-
continue;
|
|
1120
|
-
}
|
|
1121
|
-
push({
|
|
1326
|
+
if (value === "\"") {
|
|
1327
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1328
|
+
if (opts.keepQuotes === true) push({
|
|
1122
1329
|
type: "text",
|
|
1123
1330
|
value
|
|
1124
1331
|
});
|
|
1125
1332
|
continue;
|
|
1126
1333
|
}
|
|
1127
1334
|
/**
|
|
1128
|
-
*
|
|
1335
|
+
* Parentheses
|
|
1129
1336
|
*/
|
|
1130
|
-
if (value
|
|
1131
|
-
|
|
1132
|
-
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1133
|
-
if (match) {
|
|
1134
|
-
value += match[0];
|
|
1135
|
-
state.index += match[0].length;
|
|
1136
|
-
}
|
|
1337
|
+
if (value === "(") {
|
|
1338
|
+
increment("parens");
|
|
1137
1339
|
push({
|
|
1138
|
-
type: "
|
|
1340
|
+
type: "paren",
|
|
1139
1341
|
value
|
|
1140
1342
|
});
|
|
1141
1343
|
continue;
|
|
1142
1344
|
}
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1345
|
+
if (value === ")") {
|
|
1346
|
+
if (state.parens === 0 && opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "("));
|
|
1347
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1348
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1349
|
+
extglobClose(extglobs.pop());
|
|
1350
|
+
continue;
|
|
1351
|
+
}
|
|
1352
|
+
push({
|
|
1353
|
+
type: "paren",
|
|
1354
|
+
value,
|
|
1355
|
+
output: state.parens ? ")" : "\\)"
|
|
1356
|
+
});
|
|
1357
|
+
decrement("parens");
|
|
1154
1358
|
continue;
|
|
1155
1359
|
}
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1360
|
+
/**
|
|
1361
|
+
* Square brackets
|
|
1362
|
+
*/
|
|
1363
|
+
if (value === "[") {
|
|
1364
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1365
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1366
|
+
value = `\\${value}`;
|
|
1367
|
+
} else increment("brackets");
|
|
1368
|
+
push({
|
|
1369
|
+
type: "bracket",
|
|
1370
|
+
value
|
|
1371
|
+
});
|
|
1159
1372
|
continue;
|
|
1160
1373
|
}
|
|
1161
|
-
if (
|
|
1162
|
-
if (opts.
|
|
1163
|
-
|
|
1374
|
+
if (value === "]") {
|
|
1375
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1376
|
+
push({
|
|
1377
|
+
type: "text",
|
|
1378
|
+
value,
|
|
1379
|
+
output: `\\${value}`
|
|
1380
|
+
});
|
|
1164
1381
|
continue;
|
|
1165
1382
|
}
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1169
|
-
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1170
|
-
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1383
|
+
if (state.brackets === 0) {
|
|
1384
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("opening", "["));
|
|
1171
1385
|
push({
|
|
1172
|
-
type: "
|
|
1386
|
+
type: "text",
|
|
1173
1387
|
value,
|
|
1174
|
-
output:
|
|
1388
|
+
output: `\\${value}`
|
|
1175
1389
|
});
|
|
1176
1390
|
continue;
|
|
1177
1391
|
}
|
|
1178
|
-
|
|
1179
|
-
const
|
|
1180
|
-
if (
|
|
1392
|
+
decrement("brackets");
|
|
1393
|
+
const prevValue = prev.value.slice(1);
|
|
1394
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) value = `/${value}`;
|
|
1395
|
+
prev.value += value;
|
|
1396
|
+
append({ value });
|
|
1397
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) continue;
|
|
1398
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1399
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1400
|
+
if (opts.literalBrackets === true) {
|
|
1401
|
+
state.output += escaped;
|
|
1402
|
+
prev.value = escaped;
|
|
1403
|
+
continue;
|
|
1404
|
+
}
|
|
1405
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1406
|
+
state.output += prev.value;
|
|
1407
|
+
continue;
|
|
1408
|
+
}
|
|
1409
|
+
/**
|
|
1410
|
+
* Braces
|
|
1411
|
+
*/
|
|
1412
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1413
|
+
increment("braces");
|
|
1414
|
+
const open = {
|
|
1415
|
+
type: "brace",
|
|
1416
|
+
value,
|
|
1417
|
+
output: "(",
|
|
1418
|
+
outputIndex: state.output.length,
|
|
1419
|
+
tokensIndex: state.tokens.length
|
|
1420
|
+
};
|
|
1421
|
+
braces.push(open);
|
|
1422
|
+
push(open);
|
|
1423
|
+
continue;
|
|
1424
|
+
}
|
|
1425
|
+
if (value === "}") {
|
|
1426
|
+
const brace = braces[braces.length - 1];
|
|
1427
|
+
if (opts.nobrace === true || !brace) {
|
|
1181
1428
|
push({
|
|
1182
|
-
type: "
|
|
1429
|
+
type: "text",
|
|
1183
1430
|
value,
|
|
1184
|
-
output:
|
|
1431
|
+
output: value
|
|
1185
1432
|
});
|
|
1186
1433
|
continue;
|
|
1187
1434
|
}
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1435
|
+
let output = ")";
|
|
1436
|
+
if (brace.dots === true) {
|
|
1437
|
+
const arr = tokens.slice();
|
|
1438
|
+
const range = [];
|
|
1439
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1440
|
+
tokens.pop();
|
|
1441
|
+
if (arr[i].type === "brace") break;
|
|
1442
|
+
if (arr[i].type !== "dots") range.unshift(arr[i].value);
|
|
1443
|
+
}
|
|
1444
|
+
output = expandRange(range, opts);
|
|
1445
|
+
state.backtrack = true;
|
|
1193
1446
|
}
|
|
1194
|
-
if (
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
state.
|
|
1200
|
-
|
|
1447
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1448
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1449
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1450
|
+
brace.value = brace.output = "\\{";
|
|
1451
|
+
value = output = "\\}";
|
|
1452
|
+
state.output = out;
|
|
1453
|
+
for (const t of toks) state.output += t.output || t.value;
|
|
1454
|
+
}
|
|
1455
|
+
push({
|
|
1456
|
+
type: "brace",
|
|
1457
|
+
value,
|
|
1458
|
+
output
|
|
1459
|
+
});
|
|
1460
|
+
decrement("braces");
|
|
1461
|
+
braces.pop();
|
|
1462
|
+
continue;
|
|
1463
|
+
}
|
|
1464
|
+
/**
|
|
1465
|
+
* Pipes
|
|
1466
|
+
*/
|
|
1467
|
+
if (value === "|") {
|
|
1468
|
+
if (extglobs.length > 0) extglobs[extglobs.length - 1].conditions++;
|
|
1469
|
+
push({
|
|
1470
|
+
type: "text",
|
|
1471
|
+
value
|
|
1472
|
+
});
|
|
1473
|
+
continue;
|
|
1474
|
+
}
|
|
1475
|
+
/**
|
|
1476
|
+
* Commas
|
|
1477
|
+
*/
|
|
1478
|
+
if (value === ",") {
|
|
1479
|
+
let output = value;
|
|
1480
|
+
const brace = braces[braces.length - 1];
|
|
1481
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1482
|
+
brace.comma = true;
|
|
1483
|
+
output = "|";
|
|
1484
|
+
}
|
|
1485
|
+
push({
|
|
1486
|
+
type: "comma",
|
|
1487
|
+
value,
|
|
1488
|
+
output
|
|
1489
|
+
});
|
|
1490
|
+
continue;
|
|
1491
|
+
}
|
|
1492
|
+
/**
|
|
1493
|
+
* Slashes
|
|
1494
|
+
*/
|
|
1495
|
+
if (value === "/") {
|
|
1496
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1497
|
+
state.start = state.index + 1;
|
|
1498
|
+
state.consumed = "";
|
|
1499
|
+
state.output = "";
|
|
1500
|
+
tokens.pop();
|
|
1501
|
+
prev = bos;
|
|
1201
1502
|
continue;
|
|
1202
1503
|
}
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1504
|
+
push({
|
|
1505
|
+
type: "slash",
|
|
1506
|
+
value,
|
|
1507
|
+
output: SLASH_LITERAL
|
|
1508
|
+
});
|
|
1509
|
+
continue;
|
|
1510
|
+
}
|
|
1511
|
+
/**
|
|
1512
|
+
* Dots
|
|
1513
|
+
*/
|
|
1514
|
+
if (value === ".") {
|
|
1515
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1516
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1517
|
+
const brace = braces[braces.length - 1];
|
|
1518
|
+
prev.type = "dots";
|
|
1519
|
+
prev.output += value;
|
|
1208
1520
|
prev.value += value;
|
|
1209
|
-
|
|
1210
|
-
state.output += prior.output + prev.output;
|
|
1211
|
-
consume(value);
|
|
1521
|
+
brace.dots = true;
|
|
1212
1522
|
continue;
|
|
1213
1523
|
}
|
|
1214
|
-
if (
|
|
1215
|
-
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1216
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1217
|
-
prior.output = `(?:${prior.output}`;
|
|
1218
|
-
prev.type = "globstar";
|
|
1219
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1220
|
-
prev.value += value;
|
|
1221
|
-
state.output += prior.output + prev.output;
|
|
1222
|
-
state.globstar = true;
|
|
1223
|
-
consume(value + advance());
|
|
1524
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1224
1525
|
push({
|
|
1225
|
-
type: "
|
|
1226
|
-
value
|
|
1227
|
-
output:
|
|
1526
|
+
type: "text",
|
|
1527
|
+
value,
|
|
1528
|
+
output: DOT_LITERAL
|
|
1228
1529
|
});
|
|
1229
1530
|
continue;
|
|
1230
1531
|
}
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1532
|
+
push({
|
|
1533
|
+
type: "dot",
|
|
1534
|
+
value,
|
|
1535
|
+
output: DOT_LITERAL
|
|
1536
|
+
});
|
|
1537
|
+
continue;
|
|
1538
|
+
}
|
|
1539
|
+
/**
|
|
1540
|
+
* Question marks
|
|
1541
|
+
*/
|
|
1542
|
+
if (value === "?") {
|
|
1543
|
+
if (!(prev && prev.value === "(") && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1544
|
+
extglobOpen("qmark", value);
|
|
1545
|
+
continue;
|
|
1546
|
+
}
|
|
1547
|
+
if (prev && prev.type === "paren") {
|
|
1548
|
+
const next = peek();
|
|
1549
|
+
let output = value;
|
|
1550
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) output = `\\${value}`;
|
|
1238
1551
|
push({
|
|
1239
|
-
type: "
|
|
1240
|
-
value
|
|
1241
|
-
output
|
|
1552
|
+
type: "text",
|
|
1553
|
+
value,
|
|
1554
|
+
output
|
|
1242
1555
|
});
|
|
1243
1556
|
continue;
|
|
1244
1557
|
}
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1558
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1559
|
+
push({
|
|
1560
|
+
type: "qmark",
|
|
1561
|
+
value,
|
|
1562
|
+
output: QMARK_NO_DOT
|
|
1563
|
+
});
|
|
1564
|
+
continue;
|
|
1565
|
+
}
|
|
1566
|
+
push({
|
|
1567
|
+
type: "qmark",
|
|
1568
|
+
value,
|
|
1569
|
+
output: QMARK
|
|
1570
|
+
});
|
|
1571
|
+
continue;
|
|
1572
|
+
}
|
|
1573
|
+
/**
|
|
1574
|
+
* Exclamation
|
|
1575
|
+
*/
|
|
1576
|
+
if (value === "!") {
|
|
1577
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1578
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1579
|
+
extglobOpen("negate", value);
|
|
1580
|
+
continue;
|
|
1581
|
+
}
|
|
1582
|
+
}
|
|
1583
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1584
|
+
negate();
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
/**
|
|
1589
|
+
* Plus
|
|
1590
|
+
*/
|
|
1591
|
+
if (value === "+") {
|
|
1592
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1593
|
+
extglobOpen("plus", value);
|
|
1594
|
+
continue;
|
|
1595
|
+
}
|
|
1596
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1597
|
+
push({
|
|
1598
|
+
type: "plus",
|
|
1599
|
+
value,
|
|
1600
|
+
output: PLUS_LITERAL
|
|
1601
|
+
});
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1605
|
+
push({
|
|
1606
|
+
type: "plus",
|
|
1607
|
+
value
|
|
1608
|
+
});
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
push({
|
|
1612
|
+
type: "plus",
|
|
1613
|
+
value: PLUS_LITERAL
|
|
1614
|
+
});
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
/**
|
|
1618
|
+
* Plain text
|
|
1619
|
+
*/
|
|
1620
|
+
if (value === "@") {
|
|
1621
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1622
|
+
push({
|
|
1623
|
+
type: "at",
|
|
1624
|
+
extglob: true,
|
|
1625
|
+
value,
|
|
1626
|
+
output: ""
|
|
1627
|
+
});
|
|
1628
|
+
continue;
|
|
1629
|
+
}
|
|
1630
|
+
push({
|
|
1631
|
+
type: "text",
|
|
1632
|
+
value
|
|
1633
|
+
});
|
|
1634
|
+
continue;
|
|
1635
|
+
}
|
|
1636
|
+
/**
|
|
1637
|
+
* Plain text
|
|
1638
|
+
*/
|
|
1639
|
+
if (value !== "*") {
|
|
1640
|
+
if (value === "$" || value === "^") value = `\\${value}`;
|
|
1641
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1642
|
+
if (match) {
|
|
1643
|
+
value += match[0];
|
|
1644
|
+
state.index += match[0].length;
|
|
1645
|
+
}
|
|
1646
|
+
push({
|
|
1647
|
+
type: "text",
|
|
1648
|
+
value
|
|
1649
|
+
});
|
|
1650
|
+
continue;
|
|
1651
|
+
}
|
|
1652
|
+
/**
|
|
1653
|
+
* Stars
|
|
1654
|
+
*/
|
|
1655
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1656
|
+
prev.type = "star";
|
|
1657
|
+
prev.star = true;
|
|
1658
|
+
prev.value += value;
|
|
1659
|
+
prev.output = star;
|
|
1660
|
+
state.backtrack = true;
|
|
1661
|
+
state.globstar = true;
|
|
1662
|
+
consume(value);
|
|
1663
|
+
continue;
|
|
1664
|
+
}
|
|
1665
|
+
let rest = remaining();
|
|
1666
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1667
|
+
extglobOpen("star", value);
|
|
1668
|
+
continue;
|
|
1669
|
+
}
|
|
1670
|
+
if (prev.type === "star") {
|
|
1671
|
+
if (opts.noglobstar === true) {
|
|
1672
|
+
consume(value);
|
|
1673
|
+
continue;
|
|
1674
|
+
}
|
|
1675
|
+
const prior = prev.prev;
|
|
1676
|
+
const before = prior.prev;
|
|
1677
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
1678
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
1679
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
1680
|
+
push({
|
|
1681
|
+
type: "star",
|
|
1682
|
+
value,
|
|
1683
|
+
output: ""
|
|
1684
|
+
});
|
|
1685
|
+
continue;
|
|
1686
|
+
}
|
|
1687
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
1688
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
1689
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
1690
|
+
push({
|
|
1691
|
+
type: "star",
|
|
1692
|
+
value,
|
|
1693
|
+
output: ""
|
|
1694
|
+
});
|
|
1695
|
+
continue;
|
|
1696
|
+
}
|
|
1697
|
+
while (rest.slice(0, 3) === "/**") {
|
|
1698
|
+
const after = input[state.index + 4];
|
|
1699
|
+
if (after && after !== "/") break;
|
|
1700
|
+
rest = rest.slice(3);
|
|
1701
|
+
consume("/**", 3);
|
|
1702
|
+
}
|
|
1703
|
+
if (prior.type === "bos" && eos()) {
|
|
1704
|
+
prev.type = "globstar";
|
|
1705
|
+
prev.value += value;
|
|
1706
|
+
prev.output = globstar(opts);
|
|
1707
|
+
state.output = prev.output;
|
|
1708
|
+
state.globstar = true;
|
|
1709
|
+
consume(value);
|
|
1710
|
+
continue;
|
|
1711
|
+
}
|
|
1712
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
1713
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1714
|
+
prior.output = `(?:${prior.output}`;
|
|
1715
|
+
prev.type = "globstar";
|
|
1716
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
1717
|
+
prev.value += value;
|
|
1718
|
+
state.globstar = true;
|
|
1719
|
+
state.output += prior.output + prev.output;
|
|
1720
|
+
consume(value);
|
|
1721
|
+
continue;
|
|
1722
|
+
}
|
|
1723
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
1724
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
1725
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
1726
|
+
prior.output = `(?:${prior.output}`;
|
|
1727
|
+
prev.type = "globstar";
|
|
1728
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
1729
|
+
prev.value += value;
|
|
1730
|
+
state.output += prior.output + prev.output;
|
|
1731
|
+
state.globstar = true;
|
|
1732
|
+
consume(value + advance());
|
|
1733
|
+
push({
|
|
1734
|
+
type: "slash",
|
|
1735
|
+
value: "/",
|
|
1736
|
+
output: ""
|
|
1737
|
+
});
|
|
1738
|
+
continue;
|
|
1739
|
+
}
|
|
1740
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
1741
|
+
prev.type = "globstar";
|
|
1742
|
+
prev.value += value;
|
|
1743
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
1744
|
+
state.output = prev.output;
|
|
1745
|
+
state.globstar = true;
|
|
1746
|
+
consume(value + advance());
|
|
1747
|
+
push({
|
|
1748
|
+
type: "slash",
|
|
1749
|
+
value: "/",
|
|
1750
|
+
output: ""
|
|
1751
|
+
});
|
|
1752
|
+
continue;
|
|
1753
|
+
}
|
|
1754
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1755
|
+
prev.type = "globstar";
|
|
1756
|
+
prev.output = globstar(opts);
|
|
1757
|
+
prev.value += value;
|
|
1758
|
+
state.output += prev.output;
|
|
1759
|
+
state.globstar = true;
|
|
1760
|
+
consume(value);
|
|
1761
|
+
continue;
|
|
1762
|
+
}
|
|
1254
1763
|
const token = {
|
|
1255
1764
|
type: "star",
|
|
1256
1765
|
value,
|
|
@@ -1265,923 +1774,414 @@ var require_parse = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
1265
1774
|
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
1266
1775
|
token.output = value;
|
|
1267
1776
|
push(token);
|
|
1268
|
-
continue;
|
|
1269
|
-
}
|
|
1270
|
-
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1271
|
-
if (prev.type === "dot") {
|
|
1272
|
-
state.output += NO_DOT_SLASH;
|
|
1273
|
-
prev.output += NO_DOT_SLASH;
|
|
1274
|
-
} else if (opts.dot === true) {
|
|
1275
|
-
state.output += NO_DOTS_SLASH;
|
|
1276
|
-
prev.output += NO_DOTS_SLASH;
|
|
1277
|
-
} else {
|
|
1278
|
-
state.output += nodot;
|
|
1279
|
-
prev.output += nodot;
|
|
1280
|
-
}
|
|
1281
|
-
if (peek() !== "*") {
|
|
1282
|
-
state.output += ONE_CHAR;
|
|
1283
|
-
prev.output += ONE_CHAR;
|
|
1284
|
-
}
|
|
1285
|
-
}
|
|
1286
|
-
push(token);
|
|
1287
|
-
}
|
|
1288
|
-
while (state.brackets > 0) {
|
|
1289
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1290
|
-
state.output = utils.escapeLast(state.output, "[");
|
|
1291
|
-
decrement("brackets");
|
|
1292
|
-
}
|
|
1293
|
-
while (state.parens > 0) {
|
|
1294
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1295
|
-
state.output = utils.escapeLast(state.output, "(");
|
|
1296
|
-
decrement("parens");
|
|
1297
|
-
}
|
|
1298
|
-
while (state.braces > 0) {
|
|
1299
|
-
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1300
|
-
state.output = utils.escapeLast(state.output, "{");
|
|
1301
|
-
decrement("braces");
|
|
1302
|
-
}
|
|
1303
|
-
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
1304
|
-
type: "maybe_slash",
|
|
1305
|
-
value: "",
|
|
1306
|
-
output: `${SLASH_LITERAL}?`
|
|
1307
|
-
});
|
|
1308
|
-
if (state.backtrack === true) {
|
|
1309
|
-
state.output = "";
|
|
1310
|
-
for (const token of state.tokens) {
|
|
1311
|
-
state.output += token.output != null ? token.output : token.value;
|
|
1312
|
-
if (token.suffix) state.output += token.suffix;
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
return state;
|
|
1316
|
-
};
|
|
1317
|
-
/**
|
|
1318
|
-
* Fast paths for creating regular expressions for common glob patterns.
|
|
1319
|
-
* This can significantly speed up processing and has very little downside
|
|
1320
|
-
* impact when none of the fast paths match.
|
|
1321
|
-
*/
|
|
1322
|
-
parse.fastpaths = (input, options) => {
|
|
1323
|
-
const opts = { ...options };
|
|
1324
|
-
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1325
|
-
const len = input.length;
|
|
1326
|
-
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1327
|
-
input = REPLACEMENTS[input] || input;
|
|
1328
|
-
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
1329
|
-
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1330
|
-
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1331
|
-
const capture = opts.capture ? "" : "?:";
|
|
1332
|
-
const state = {
|
|
1333
|
-
negated: false,
|
|
1334
|
-
prefix: ""
|
|
1335
|
-
};
|
|
1336
|
-
let star = opts.bash === true ? ".*?" : STAR;
|
|
1337
|
-
if (opts.capture) star = `(${star})`;
|
|
1338
|
-
const globstar = (opts$1) => {
|
|
1339
|
-
if (opts$1.noglobstar === true) return star;
|
|
1340
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1341
|
-
};
|
|
1342
|
-
const create = (str) => {
|
|
1343
|
-
switch (str) {
|
|
1344
|
-
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
1345
|
-
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1346
|
-
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1347
|
-
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1348
|
-
case "**": return nodot + globstar(opts);
|
|
1349
|
-
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1350
|
-
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1351
|
-
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1352
|
-
default: {
|
|
1353
|
-
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1354
|
-
if (!match) return;
|
|
1355
|
-
const source$1 = create(match[1]);
|
|
1356
|
-
if (!source$1) return;
|
|
1357
|
-
return source$1 + DOT_LITERAL + match[2];
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
};
|
|
1361
|
-
let source = create(utils.removePrefix(input, state));
|
|
1362
|
-
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
1363
|
-
return source;
|
|
1364
|
-
};
|
|
1365
|
-
module.exports = parse;
|
|
1366
|
-
}));
|
|
1367
|
-
|
|
1368
|
-
//#endregion
|
|
1369
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1370
|
-
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1371
|
-
const scan = require_scan();
|
|
1372
|
-
const parse = require_parse();
|
|
1373
|
-
const utils = require_utils();
|
|
1374
|
-
const constants = require_constants();
|
|
1375
|
-
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1376
|
-
/**
|
|
1377
|
-
* Creates a matcher function from one or more glob patterns. The
|
|
1378
|
-
* returned function takes a string to match as its first argument,
|
|
1379
|
-
* and returns true if the string is a match. The returned matcher
|
|
1380
|
-
* function also takes a boolean as the second argument that, when true,
|
|
1381
|
-
* returns an object with additional information.
|
|
1382
|
-
*
|
|
1383
|
-
* ```js
|
|
1384
|
-
* const picomatch = require('picomatch');
|
|
1385
|
-
* // picomatch(glob[, options]);
|
|
1386
|
-
*
|
|
1387
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
1388
|
-
* console.log(isMatch('a.a')); //=> false
|
|
1389
|
-
* console.log(isMatch('a.b')); //=> true
|
|
1390
|
-
* ```
|
|
1391
|
-
* @name picomatch
|
|
1392
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
1393
|
-
* @param {Object=} `options`
|
|
1394
|
-
* @return {Function=} Returns a matcher function.
|
|
1395
|
-
* @api public
|
|
1396
|
-
*/
|
|
1397
|
-
const picomatch = (glob, options, returnState = false) => {
|
|
1398
|
-
if (Array.isArray(glob)) {
|
|
1399
|
-
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1400
|
-
const arrayMatcher = (str) => {
|
|
1401
|
-
for (const isMatch of fns) {
|
|
1402
|
-
const state$1 = isMatch(str);
|
|
1403
|
-
if (state$1) return state$1;
|
|
1404
|
-
}
|
|
1405
|
-
return false;
|
|
1406
|
-
};
|
|
1407
|
-
return arrayMatcher;
|
|
1408
|
-
}
|
|
1409
|
-
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1410
|
-
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
1411
|
-
const opts = options || {};
|
|
1412
|
-
const posix$1 = opts.windows;
|
|
1413
|
-
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1414
|
-
const state = regex.state;
|
|
1415
|
-
delete regex.state;
|
|
1416
|
-
let isIgnored = () => false;
|
|
1417
|
-
if (opts.ignore) {
|
|
1418
|
-
const ignoreOpts = {
|
|
1419
|
-
...options,
|
|
1420
|
-
ignore: null,
|
|
1421
|
-
onMatch: null,
|
|
1422
|
-
onResult: null
|
|
1423
|
-
};
|
|
1424
|
-
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1425
|
-
}
|
|
1426
|
-
const matcher = (input, returnObject = false) => {
|
|
1427
|
-
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1428
|
-
glob,
|
|
1429
|
-
posix: posix$1
|
|
1430
|
-
});
|
|
1431
|
-
const result = {
|
|
1432
|
-
glob,
|
|
1433
|
-
state,
|
|
1434
|
-
regex,
|
|
1435
|
-
posix: posix$1,
|
|
1436
|
-
input,
|
|
1437
|
-
output,
|
|
1438
|
-
match,
|
|
1439
|
-
isMatch
|
|
1440
|
-
};
|
|
1441
|
-
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
1442
|
-
if (isMatch === false) {
|
|
1443
|
-
result.isMatch = false;
|
|
1444
|
-
return returnObject ? result : false;
|
|
1445
|
-
}
|
|
1446
|
-
if (isIgnored(input)) {
|
|
1447
|
-
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
1448
|
-
result.isMatch = false;
|
|
1449
|
-
return returnObject ? result : false;
|
|
1450
|
-
}
|
|
1451
|
-
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
1452
|
-
return returnObject ? result : true;
|
|
1453
|
-
};
|
|
1454
|
-
if (returnState) matcher.state = state;
|
|
1455
|
-
return matcher;
|
|
1456
|
-
};
|
|
1457
|
-
/**
|
|
1458
|
-
* Test `input` with the given `regex`. This is used by the main
|
|
1459
|
-
* `picomatch()` function to test the input string.
|
|
1460
|
-
*
|
|
1461
|
-
* ```js
|
|
1462
|
-
* const picomatch = require('picomatch');
|
|
1463
|
-
* // picomatch.test(input, regex[, options]);
|
|
1464
|
-
*
|
|
1465
|
-
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
1466
|
-
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
1467
|
-
* ```
|
|
1468
|
-
* @param {String} `input` String to test.
|
|
1469
|
-
* @param {RegExp} `regex`
|
|
1470
|
-
* @return {Object} Returns an object with matching info.
|
|
1471
|
-
* @api public
|
|
1472
|
-
*/
|
|
1473
|
-
picomatch.test = (input, regex, options, { glob, posix: posix$1 } = {}) => {
|
|
1474
|
-
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
1475
|
-
if (input === "") return {
|
|
1476
|
-
isMatch: false,
|
|
1477
|
-
output: ""
|
|
1478
|
-
};
|
|
1479
|
-
const opts = options || {};
|
|
1480
|
-
const format = opts.format || (posix$1 ? utils.toPosixSlashes : null);
|
|
1481
|
-
let match = input === glob;
|
|
1482
|
-
let output = match && format ? format(input) : input;
|
|
1483
|
-
if (match === false) {
|
|
1484
|
-
output = format ? format(input) : input;
|
|
1485
|
-
match = output === glob;
|
|
1486
|
-
}
|
|
1487
|
-
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix$1);
|
|
1488
|
-
else match = regex.exec(output);
|
|
1489
|
-
return {
|
|
1490
|
-
isMatch: Boolean(match),
|
|
1491
|
-
match,
|
|
1492
|
-
output
|
|
1493
|
-
};
|
|
1494
|
-
};
|
|
1495
|
-
/**
|
|
1496
|
-
* Match the basename of a filepath.
|
|
1497
|
-
*
|
|
1498
|
-
* ```js
|
|
1499
|
-
* const picomatch = require('picomatch');
|
|
1500
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
1501
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
1502
|
-
* ```
|
|
1503
|
-
* @param {String} `input` String to test.
|
|
1504
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
1505
|
-
* @return {Boolean}
|
|
1506
|
-
* @api public
|
|
1507
|
-
*/
|
|
1508
|
-
picomatch.matchBase = (input, glob, options) => {
|
|
1509
|
-
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
1510
|
-
};
|
|
1511
|
-
/**
|
|
1512
|
-
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
1513
|
-
*
|
|
1514
|
-
* ```js
|
|
1515
|
-
* const picomatch = require('picomatch');
|
|
1516
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
1517
|
-
*
|
|
1518
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
1519
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
1520
|
-
* ```
|
|
1521
|
-
* @param {String|Array} str The string to test.
|
|
1522
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
1523
|
-
* @param {Object} [options] See available [options](#options).
|
|
1524
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
1525
|
-
* @api public
|
|
1526
|
-
*/
|
|
1527
|
-
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
1528
|
-
/**
|
|
1529
|
-
* Parse a glob pattern to create the source string for a regular
|
|
1530
|
-
* expression.
|
|
1531
|
-
*
|
|
1532
|
-
* ```js
|
|
1533
|
-
* const picomatch = require('picomatch');
|
|
1534
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
1535
|
-
* ```
|
|
1536
|
-
* @param {String} `pattern`
|
|
1537
|
-
* @param {Object} `options`
|
|
1538
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
1539
|
-
* @api public
|
|
1540
|
-
*/
|
|
1541
|
-
picomatch.parse = (pattern, options) => {
|
|
1542
|
-
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
1543
|
-
return parse(pattern, {
|
|
1544
|
-
...options,
|
|
1545
|
-
fastpaths: false
|
|
1546
|
-
});
|
|
1547
|
-
};
|
|
1548
|
-
/**
|
|
1549
|
-
* Scan a glob pattern to separate the pattern into segments.
|
|
1550
|
-
*
|
|
1551
|
-
* ```js
|
|
1552
|
-
* const picomatch = require('picomatch');
|
|
1553
|
-
* // picomatch.scan(input[, options]);
|
|
1554
|
-
*
|
|
1555
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
1556
|
-
* console.log(result);
|
|
1557
|
-
* { prefix: '!./',
|
|
1558
|
-
* input: '!./foo/*.js',
|
|
1559
|
-
* start: 3,
|
|
1560
|
-
* base: 'foo',
|
|
1561
|
-
* glob: '*.js',
|
|
1562
|
-
* isBrace: false,
|
|
1563
|
-
* isBracket: false,
|
|
1564
|
-
* isGlob: true,
|
|
1565
|
-
* isExtglob: false,
|
|
1566
|
-
* isGlobstar: false,
|
|
1567
|
-
* negated: true }
|
|
1568
|
-
* ```
|
|
1569
|
-
* @param {String} `input` Glob pattern to scan.
|
|
1570
|
-
* @param {Object} `options`
|
|
1571
|
-
* @return {Object} Returns an object with
|
|
1572
|
-
* @api public
|
|
1573
|
-
*/
|
|
1574
|
-
picomatch.scan = (input, options) => scan(input, options);
|
|
1575
|
-
/**
|
|
1576
|
-
* Compile a regular expression from the `state` object returned by the
|
|
1577
|
-
* [parse()](#parse) method.
|
|
1578
|
-
*
|
|
1579
|
-
* @param {Object} `state`
|
|
1580
|
-
* @param {Object} `options`
|
|
1581
|
-
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
1582
|
-
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
1583
|
-
* @return {RegExp}
|
|
1584
|
-
* @api public
|
|
1585
|
-
*/
|
|
1586
|
-
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
1587
|
-
if (returnOutput === true) return state.output;
|
|
1588
|
-
const opts = options || {};
|
|
1589
|
-
const prepend = opts.contains ? "" : "^";
|
|
1590
|
-
const append = opts.contains ? "" : "$";
|
|
1591
|
-
let source = `${prepend}(?:${state.output})${append}`;
|
|
1592
|
-
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
1593
|
-
const regex = picomatch.toRegex(source, options);
|
|
1594
|
-
if (returnState === true) regex.state = state;
|
|
1595
|
-
return regex;
|
|
1596
|
-
};
|
|
1597
|
-
/**
|
|
1598
|
-
* Create a regular expression from a parsed glob pattern.
|
|
1599
|
-
*
|
|
1600
|
-
* ```js
|
|
1601
|
-
* const picomatch = require('picomatch');
|
|
1602
|
-
* const state = picomatch.parse('*.js');
|
|
1603
|
-
* // picomatch.compileRe(state[, options]);
|
|
1604
|
-
*
|
|
1605
|
-
* console.log(picomatch.compileRe(state));
|
|
1606
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1607
|
-
* ```
|
|
1608
|
-
* @param {String} `state` The object returned from the `.parse` method.
|
|
1609
|
-
* @param {Object} `options`
|
|
1610
|
-
* @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.
|
|
1611
|
-
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
1612
|
-
* @return {RegExp} Returns a regex created from the given pattern.
|
|
1613
|
-
* @api public
|
|
1614
|
-
*/
|
|
1615
|
-
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
1616
|
-
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
1617
|
-
let parsed = {
|
|
1618
|
-
negated: false,
|
|
1619
|
-
fastpaths: true
|
|
1620
|
-
};
|
|
1621
|
-
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
1622
|
-
if (!parsed.output) parsed = parse(input, options);
|
|
1623
|
-
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
1624
|
-
};
|
|
1625
|
-
/**
|
|
1626
|
-
* Create a regular expression from the given regex source string.
|
|
1627
|
-
*
|
|
1628
|
-
* ```js
|
|
1629
|
-
* const picomatch = require('picomatch');
|
|
1630
|
-
* // picomatch.toRegex(source[, options]);
|
|
1631
|
-
*
|
|
1632
|
-
* const { output } = picomatch.parse('*.js');
|
|
1633
|
-
* console.log(picomatch.toRegex(output));
|
|
1634
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
1635
|
-
* ```
|
|
1636
|
-
* @param {String} `source` Regular expression source string.
|
|
1637
|
-
* @param {Object} `options`
|
|
1638
|
-
* @return {RegExp}
|
|
1639
|
-
* @api public
|
|
1640
|
-
*/
|
|
1641
|
-
picomatch.toRegex = (source, options) => {
|
|
1642
|
-
try {
|
|
1643
|
-
const opts = options || {};
|
|
1644
|
-
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
1645
|
-
} catch (err) {
|
|
1646
|
-
if (options && options.debug === true) throw err;
|
|
1647
|
-
return /$^/;
|
|
1648
|
-
}
|
|
1649
|
-
};
|
|
1650
|
-
/**
|
|
1651
|
-
* Picomatch constants.
|
|
1652
|
-
* @return {Object}
|
|
1653
|
-
*/
|
|
1654
|
-
picomatch.constants = constants;
|
|
1655
|
-
/**
|
|
1656
|
-
* Expose "picomatch"
|
|
1657
|
-
*/
|
|
1658
|
-
module.exports = picomatch;
|
|
1659
|
-
}));
|
|
1660
|
-
|
|
1661
|
-
//#endregion
|
|
1662
|
-
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
1663
|
-
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1664
|
-
const pico = require_picomatch$1();
|
|
1665
|
-
const utils = require_utils();
|
|
1666
|
-
function picomatch(glob, options, returnState = false) {
|
|
1667
|
-
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
1668
|
-
...options,
|
|
1669
|
-
windows: utils.isWindows()
|
|
1670
|
-
};
|
|
1671
|
-
return pico(glob, options, returnState);
|
|
1672
|
-
}
|
|
1673
|
-
Object.assign(picomatch, pico);
|
|
1674
|
-
module.exports = picomatch;
|
|
1675
|
-
}));
|
|
1676
|
-
|
|
1677
|
-
//#endregion
|
|
1678
|
-
//#region node_modules/.pnpm/fdir@6.5.0_picomatch@4.0.3/node_modules/fdir/dist/index.mjs
|
|
1679
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
1680
|
-
function cleanPath(path$2) {
|
|
1681
|
-
let normalized = normalize(path$2);
|
|
1682
|
-
if (normalized.length > 1 && normalized[normalized.length - 1] === sep) normalized = normalized.substring(0, normalized.length - 1);
|
|
1683
|
-
return normalized;
|
|
1684
|
-
}
|
|
1685
|
-
const SLASHES_REGEX = /[\\/]/g;
|
|
1686
|
-
function convertSlashes(path$2, separator) {
|
|
1687
|
-
return path$2.replace(SLASHES_REGEX, separator);
|
|
1688
|
-
}
|
|
1689
|
-
const WINDOWS_ROOT_DIR_REGEX = /^[a-z]:[\\/]$/i;
|
|
1690
|
-
function isRootDirectory(path$2) {
|
|
1691
|
-
return path$2 === "/" || WINDOWS_ROOT_DIR_REGEX.test(path$2);
|
|
1692
|
-
}
|
|
1693
|
-
function normalizePath$1(path$2, options) {
|
|
1694
|
-
const { resolvePaths, normalizePath: normalizePath$1$1, pathSeparator } = options;
|
|
1695
|
-
const pathNeedsCleaning = process.platform === "win32" && path$2.includes("/") || path$2.startsWith(".");
|
|
1696
|
-
if (resolvePaths) path$2 = resolve(path$2);
|
|
1697
|
-
if (normalizePath$1$1 || pathNeedsCleaning) path$2 = cleanPath(path$2);
|
|
1698
|
-
if (path$2 === ".") return "";
|
|
1699
|
-
return convertSlashes(path$2[path$2.length - 1] !== pathSeparator ? path$2 + pathSeparator : path$2, pathSeparator);
|
|
1700
|
-
}
|
|
1701
|
-
function joinPathWithBasePath(filename, directoryPath) {
|
|
1702
|
-
return directoryPath + filename;
|
|
1703
|
-
}
|
|
1704
|
-
function joinPathWithRelativePath(root, options) {
|
|
1705
|
-
return function(filename, directoryPath) {
|
|
1706
|
-
if (directoryPath.startsWith(root)) return directoryPath.slice(root.length) + filename;
|
|
1707
|
-
else return convertSlashes(relative(root, directoryPath), options.pathSeparator) + options.pathSeparator + filename;
|
|
1708
|
-
};
|
|
1709
|
-
}
|
|
1710
|
-
function joinPath(filename) {
|
|
1711
|
-
return filename;
|
|
1712
|
-
}
|
|
1713
|
-
function joinDirectoryPath(filename, directoryPath, separator) {
|
|
1714
|
-
return directoryPath + filename + separator;
|
|
1715
|
-
}
|
|
1716
|
-
function build$7(root, options) {
|
|
1717
|
-
const { relativePaths, includeBasePath } = options;
|
|
1718
|
-
return relativePaths && root ? joinPathWithRelativePath(root, options) : includeBasePath ? joinPathWithBasePath : joinPath;
|
|
1719
|
-
}
|
|
1720
|
-
function pushDirectoryWithRelativePath(root) {
|
|
1721
|
-
return function(directoryPath, paths) {
|
|
1722
|
-
paths.push(directoryPath.substring(root.length) || ".");
|
|
1723
|
-
};
|
|
1724
|
-
}
|
|
1725
|
-
function pushDirectoryFilterWithRelativePath(root) {
|
|
1726
|
-
return function(directoryPath, paths, filters) {
|
|
1727
|
-
const relativePath = directoryPath.substring(root.length) || ".";
|
|
1728
|
-
if (filters.every((filter) => filter(relativePath, true))) paths.push(relativePath);
|
|
1729
|
-
};
|
|
1730
|
-
}
|
|
1731
|
-
const pushDirectory = (directoryPath, paths) => {
|
|
1732
|
-
paths.push(directoryPath || ".");
|
|
1733
|
-
};
|
|
1734
|
-
const pushDirectoryFilter = (directoryPath, paths, filters) => {
|
|
1735
|
-
const path$2 = directoryPath || ".";
|
|
1736
|
-
if (filters.every((filter) => filter(path$2, true))) paths.push(path$2);
|
|
1737
|
-
};
|
|
1738
|
-
const empty$2 = () => {};
|
|
1739
|
-
function build$6(root, options) {
|
|
1740
|
-
const { includeDirs, filters, relativePaths } = options;
|
|
1741
|
-
if (!includeDirs) return empty$2;
|
|
1742
|
-
if (relativePaths) return filters && filters.length ? pushDirectoryFilterWithRelativePath(root) : pushDirectoryWithRelativePath(root);
|
|
1743
|
-
return filters && filters.length ? pushDirectoryFilter : pushDirectory;
|
|
1744
|
-
}
|
|
1745
|
-
const pushFileFilterAndCount = (filename, _paths, counts, filters) => {
|
|
1746
|
-
if (filters.every((filter) => filter(filename, false))) counts.files++;
|
|
1747
|
-
};
|
|
1748
|
-
const pushFileFilter = (filename, paths, _counts, filters) => {
|
|
1749
|
-
if (filters.every((filter) => filter(filename, false))) paths.push(filename);
|
|
1750
|
-
};
|
|
1751
|
-
const pushFileCount = (_filename, _paths, counts, _filters) => {
|
|
1752
|
-
counts.files++;
|
|
1753
|
-
};
|
|
1754
|
-
const pushFile = (filename, paths) => {
|
|
1755
|
-
paths.push(filename);
|
|
1756
|
-
};
|
|
1757
|
-
const empty$1 = () => {};
|
|
1758
|
-
function build$5(options) {
|
|
1759
|
-
const { excludeFiles, filters, onlyCounts } = options;
|
|
1760
|
-
if (excludeFiles) return empty$1;
|
|
1761
|
-
if (filters && filters.length) return onlyCounts ? pushFileFilterAndCount : pushFileFilter;
|
|
1762
|
-
else if (onlyCounts) return pushFileCount;
|
|
1763
|
-
else return pushFile;
|
|
1764
|
-
}
|
|
1765
|
-
const getArray = (paths) => {
|
|
1766
|
-
return paths;
|
|
1767
|
-
};
|
|
1768
|
-
const getArrayGroup = () => {
|
|
1769
|
-
return [""].slice(0, 0);
|
|
1770
|
-
};
|
|
1771
|
-
function build$4(options) {
|
|
1772
|
-
return options.group ? getArrayGroup : getArray;
|
|
1773
|
-
}
|
|
1774
|
-
const groupFiles = (groups, directory, files) => {
|
|
1775
|
-
groups.push({
|
|
1776
|
-
directory,
|
|
1777
|
-
files,
|
|
1778
|
-
dir: directory
|
|
1779
|
-
});
|
|
1780
|
-
};
|
|
1781
|
-
const empty = () => {};
|
|
1782
|
-
function build$3(options) {
|
|
1783
|
-
return options.group ? groupFiles : empty;
|
|
1784
|
-
}
|
|
1785
|
-
const resolveSymlinksAsync = function(path$2, state, callback$1) {
|
|
1786
|
-
const { queue, fs, options: { suppressErrors } } = state;
|
|
1787
|
-
queue.enqueue();
|
|
1788
|
-
fs.realpath(path$2, (error, resolvedPath) => {
|
|
1789
|
-
if (error) return queue.dequeue(suppressErrors ? null : error, state);
|
|
1790
|
-
fs.stat(resolvedPath, (error$1, stat) => {
|
|
1791
|
-
if (error$1) return queue.dequeue(suppressErrors ? null : error$1, state);
|
|
1792
|
-
if (stat.isDirectory() && isRecursive(path$2, resolvedPath, state)) return queue.dequeue(null, state);
|
|
1793
|
-
callback$1(stat, resolvedPath);
|
|
1794
|
-
queue.dequeue(null, state);
|
|
1777
|
+
continue;
|
|
1778
|
+
}
|
|
1779
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
1780
|
+
if (prev.type === "dot") {
|
|
1781
|
+
state.output += NO_DOT_SLASH;
|
|
1782
|
+
prev.output += NO_DOT_SLASH;
|
|
1783
|
+
} else if (opts.dot === true) {
|
|
1784
|
+
state.output += NO_DOTS_SLASH;
|
|
1785
|
+
prev.output += NO_DOTS_SLASH;
|
|
1786
|
+
} else {
|
|
1787
|
+
state.output += nodot;
|
|
1788
|
+
prev.output += nodot;
|
|
1789
|
+
}
|
|
1790
|
+
if (peek() !== "*") {
|
|
1791
|
+
state.output += ONE_CHAR;
|
|
1792
|
+
prev.output += ONE_CHAR;
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
push(token);
|
|
1796
|
+
}
|
|
1797
|
+
while (state.brackets > 0) {
|
|
1798
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
1799
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
1800
|
+
decrement("brackets");
|
|
1801
|
+
}
|
|
1802
|
+
while (state.parens > 0) {
|
|
1803
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
1804
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
1805
|
+
decrement("parens");
|
|
1806
|
+
}
|
|
1807
|
+
while (state.braces > 0) {
|
|
1808
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
1809
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
1810
|
+
decrement("braces");
|
|
1811
|
+
}
|
|
1812
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) push({
|
|
1813
|
+
type: "maybe_slash",
|
|
1814
|
+
value: "",
|
|
1815
|
+
output: `${SLASH_LITERAL}?`
|
|
1795
1816
|
});
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
const
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
}
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
const
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
return null;
|
|
1848
|
-
};
|
|
1849
|
-
const limitFilesAsync = (state, error, callback$1) => {
|
|
1850
|
-
report(error, callback$1, state.paths.slice(0, state.options.maxFiles), state.options.suppressErrors);
|
|
1851
|
-
return null;
|
|
1852
|
-
};
|
|
1853
|
-
const groupsAsync = (state, error, callback$1) => {
|
|
1854
|
-
report(error, callback$1, state.groups, state.options.suppressErrors);
|
|
1855
|
-
return null;
|
|
1856
|
-
};
|
|
1857
|
-
function report(error, callback$1, output, suppressErrors) {
|
|
1858
|
-
if (error && !suppressErrors) callback$1(error, output);
|
|
1859
|
-
else callback$1(null, output);
|
|
1860
|
-
}
|
|
1861
|
-
function build$1(options, isSynchronous) {
|
|
1862
|
-
const { onlyCounts, group, maxFiles } = options;
|
|
1863
|
-
if (onlyCounts) return isSynchronous ? onlyCountsSync : onlyCountsAsync;
|
|
1864
|
-
else if (group) return isSynchronous ? groupsSync : groupsAsync;
|
|
1865
|
-
else if (maxFiles) return isSynchronous ? limitFilesSync : limitFilesAsync;
|
|
1866
|
-
else return isSynchronous ? defaultSync : defaultAsync;
|
|
1867
|
-
}
|
|
1868
|
-
const readdirOpts = { withFileTypes: true };
|
|
1869
|
-
const walkAsync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
1870
|
-
state.queue.enqueue();
|
|
1871
|
-
if (currentDepth < 0) return state.queue.dequeue(null, state);
|
|
1872
|
-
const { fs } = state;
|
|
1873
|
-
state.visited.push(crawlPath);
|
|
1874
|
-
state.counts.directories++;
|
|
1875
|
-
fs.readdir(crawlPath || ".", readdirOpts, (error, entries = []) => {
|
|
1876
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1877
|
-
state.queue.dequeue(state.options.suppressErrors ? null : error, state);
|
|
1878
|
-
});
|
|
1879
|
-
};
|
|
1880
|
-
const walkSync = (state, crawlPath, directoryPath, currentDepth, callback$1) => {
|
|
1881
|
-
const { fs } = state;
|
|
1882
|
-
if (currentDepth < 0) return;
|
|
1883
|
-
state.visited.push(crawlPath);
|
|
1884
|
-
state.counts.directories++;
|
|
1885
|
-
let entries = [];
|
|
1886
|
-
try {
|
|
1887
|
-
entries = fs.readdirSync(crawlPath || ".", readdirOpts);
|
|
1888
|
-
} catch (e) {
|
|
1889
|
-
if (!state.options.suppressErrors) throw e;
|
|
1890
|
-
}
|
|
1891
|
-
callback$1(entries, directoryPath, currentDepth);
|
|
1892
|
-
};
|
|
1893
|
-
function build(isSynchronous) {
|
|
1894
|
-
return isSynchronous ? walkSync : walkAsync;
|
|
1895
|
-
}
|
|
1896
|
-
/**
|
|
1897
|
-
* This is a custom stateless queue to track concurrent async fs calls.
|
|
1898
|
-
* It increments a counter whenever a call is queued and decrements it
|
|
1899
|
-
* as soon as it completes. When the counter hits 0, it calls onQueueEmpty.
|
|
1900
|
-
*/
|
|
1901
|
-
var Queue = class {
|
|
1902
|
-
count = 0;
|
|
1903
|
-
constructor(onQueueEmpty) {
|
|
1904
|
-
this.onQueueEmpty = onQueueEmpty;
|
|
1905
|
-
}
|
|
1906
|
-
enqueue() {
|
|
1907
|
-
this.count++;
|
|
1908
|
-
return this.count;
|
|
1909
|
-
}
|
|
1910
|
-
dequeue(error, output) {
|
|
1911
|
-
if (this.onQueueEmpty && (--this.count <= 0 || error)) {
|
|
1912
|
-
this.onQueueEmpty(error, output);
|
|
1913
|
-
if (error) {
|
|
1914
|
-
output.controller.abort();
|
|
1915
|
-
this.onQueueEmpty = void 0;
|
|
1817
|
+
if (state.backtrack === true) {
|
|
1818
|
+
state.output = "";
|
|
1819
|
+
for (const token of state.tokens) {
|
|
1820
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1821
|
+
if (token.suffix) state.output += token.suffix;
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
return state;
|
|
1825
|
+
};
|
|
1826
|
+
/**
|
|
1827
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
1828
|
+
* This can significantly speed up processing and has very little downside
|
|
1829
|
+
* impact when none of the fast paths match.
|
|
1830
|
+
*/
|
|
1831
|
+
parse.fastpaths = (input, options) => {
|
|
1832
|
+
const opts = { ...options };
|
|
1833
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1834
|
+
const len = input.length;
|
|
1835
|
+
if (len > max) throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1836
|
+
input = REPLACEMENTS[input] || input;
|
|
1837
|
+
const { DOT_LITERAL, SLASH_LITERAL, ONE_CHAR, DOTS_SLASH, NO_DOT, NO_DOTS, NO_DOTS_SLASH, STAR, START_ANCHOR } = constants.globChars(opts.windows);
|
|
1838
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
1839
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
1840
|
+
const capture = opts.capture ? "" : "?:";
|
|
1841
|
+
const state = {
|
|
1842
|
+
negated: false,
|
|
1843
|
+
prefix: ""
|
|
1844
|
+
};
|
|
1845
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
1846
|
+
if (opts.capture) star = `(${star})`;
|
|
1847
|
+
const globstar = (opts$1) => {
|
|
1848
|
+
if (opts$1.noglobstar === true) return star;
|
|
1849
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts$1.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1850
|
+
};
|
|
1851
|
+
const create = (str) => {
|
|
1852
|
+
switch (str) {
|
|
1853
|
+
case "*": return `${nodot}${ONE_CHAR}${star}`;
|
|
1854
|
+
case ".*": return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1855
|
+
case "*.*": return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1856
|
+
case "*/*": return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
1857
|
+
case "**": return nodot + globstar(opts);
|
|
1858
|
+
case "**/*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
1859
|
+
case "**/*.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1860
|
+
case "**/.*": return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
1861
|
+
default: {
|
|
1862
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
1863
|
+
if (!match) return;
|
|
1864
|
+
const source$1 = create(match[1]);
|
|
1865
|
+
if (!source$1) return;
|
|
1866
|
+
return source$1 + DOT_LITERAL + match[2];
|
|
1867
|
+
}
|
|
1916
1868
|
}
|
|
1869
|
+
};
|
|
1870
|
+
let source = create(utils.removePrefix(input, state));
|
|
1871
|
+
if (source && opts.strictSlashes !== true) source += `${SLASH_LITERAL}?`;
|
|
1872
|
+
return source;
|
|
1873
|
+
};
|
|
1874
|
+
module.exports = parse;
|
|
1875
|
+
}));
|
|
1876
|
+
|
|
1877
|
+
//#endregion
|
|
1878
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/lib/picomatch.js
|
|
1879
|
+
var require_picomatch$1 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
1880
|
+
const scan = require_scan();
|
|
1881
|
+
const parse = require_parse();
|
|
1882
|
+
const utils = require_utils();
|
|
1883
|
+
const constants = require_constants();
|
|
1884
|
+
const isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
1885
|
+
/**
|
|
1886
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
1887
|
+
* returned function takes a string to match as its first argument,
|
|
1888
|
+
* and returns true if the string is a match. The returned matcher
|
|
1889
|
+
* function also takes a boolean as the second argument that, when true,
|
|
1890
|
+
* returns an object with additional information.
|
|
1891
|
+
*
|
|
1892
|
+
* ```js
|
|
1893
|
+
* const picomatch = require('picomatch');
|
|
1894
|
+
* // picomatch(glob[, options]);
|
|
1895
|
+
*
|
|
1896
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
1897
|
+
* console.log(isMatch('a.a')); //=> false
|
|
1898
|
+
* console.log(isMatch('a.b')); //=> true
|
|
1899
|
+
* ```
|
|
1900
|
+
* @name picomatch
|
|
1901
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
1902
|
+
* @param {Object=} `options`
|
|
1903
|
+
* @return {Function=} Returns a matcher function.
|
|
1904
|
+
* @api public
|
|
1905
|
+
*/
|
|
1906
|
+
const picomatch = (glob, options, returnState = false) => {
|
|
1907
|
+
if (Array.isArray(glob)) {
|
|
1908
|
+
const fns = glob.map((input) => picomatch(input, options, returnState));
|
|
1909
|
+
const arrayMatcher = (str) => {
|
|
1910
|
+
for (const isMatch of fns) {
|
|
1911
|
+
const state$1 = isMatch(str);
|
|
1912
|
+
if (state$1) return state$1;
|
|
1913
|
+
}
|
|
1914
|
+
return false;
|
|
1915
|
+
};
|
|
1916
|
+
return arrayMatcher;
|
|
1917
1917
|
}
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1918
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
1919
|
+
if (glob === "" || typeof glob !== "string" && !isState) throw new TypeError("Expected pattern to be a non-empty string");
|
|
1920
|
+
const opts = options || {};
|
|
1921
|
+
const posix$1 = opts.windows;
|
|
1922
|
+
const regex = isState ? picomatch.compileRe(glob, options) : picomatch.makeRe(glob, options, false, true);
|
|
1923
|
+
const state = regex.state;
|
|
1924
|
+
delete regex.state;
|
|
1925
|
+
let isIgnored = () => false;
|
|
1926
|
+
if (opts.ignore) {
|
|
1927
|
+
const ignoreOpts = {
|
|
1928
|
+
...options,
|
|
1929
|
+
ignore: null,
|
|
1930
|
+
onMatch: null,
|
|
1931
|
+
onResult: null
|
|
1932
|
+
};
|
|
1933
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
1934
|
+
}
|
|
1935
|
+
const matcher = (input, returnObject = false) => {
|
|
1936
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
|
1937
|
+
glob,
|
|
1938
|
+
posix: posix$1
|
|
1939
|
+
});
|
|
1940
|
+
const result = {
|
|
1941
|
+
glob,
|
|
1942
|
+
state,
|
|
1943
|
+
regex,
|
|
1944
|
+
posix: posix$1,
|
|
1945
|
+
input,
|
|
1946
|
+
output,
|
|
1947
|
+
match,
|
|
1948
|
+
isMatch
|
|
1949
|
+
};
|
|
1950
|
+
if (typeof opts.onResult === "function") opts.onResult(result);
|
|
1951
|
+
if (isMatch === false) {
|
|
1952
|
+
result.isMatch = false;
|
|
1953
|
+
return returnObject ? result : false;
|
|
1954
|
+
}
|
|
1955
|
+
if (isIgnored(input)) {
|
|
1956
|
+
if (typeof opts.onIgnore === "function") opts.onIgnore(result);
|
|
1957
|
+
result.isMatch = false;
|
|
1958
|
+
return returnObject ? result : false;
|
|
1959
|
+
}
|
|
1960
|
+
if (typeof opts.onMatch === "function") opts.onMatch(result);
|
|
1961
|
+
return returnObject ? result : true;
|
|
1962
|
+
};
|
|
1963
|
+
if (returnState) matcher.state = state;
|
|
1964
|
+
return matcher;
|
|
1965
|
+
};
|
|
1935
1966
|
/**
|
|
1936
|
-
*
|
|
1967
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
1968
|
+
* `picomatch()` function to test the input string.
|
|
1969
|
+
*
|
|
1970
|
+
* ```js
|
|
1971
|
+
* const picomatch = require('picomatch');
|
|
1972
|
+
* // picomatch.test(input, regex[, options]);
|
|
1973
|
+
*
|
|
1974
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
1975
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
1976
|
+
* ```
|
|
1977
|
+
* @param {String} `input` String to test.
|
|
1978
|
+
* @param {RegExp} `regex`
|
|
1979
|
+
* @return {Object} Returns an object with matching info.
|
|
1980
|
+
* @api public
|
|
1937
1981
|
*/
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
return
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
/**
|
|
1944
|
-
* AbortController is not supported on Node 14 so we use this until we can drop
|
|
1945
|
-
* support for Node 14.
|
|
1946
|
-
*/
|
|
1947
|
-
var Aborter = class {
|
|
1948
|
-
aborted = false;
|
|
1949
|
-
abort() {
|
|
1950
|
-
this.aborted = true;
|
|
1951
|
-
}
|
|
1952
|
-
};
|
|
1953
|
-
var Walker = class {
|
|
1954
|
-
root;
|
|
1955
|
-
isSynchronous;
|
|
1956
|
-
state;
|
|
1957
|
-
joinPath;
|
|
1958
|
-
pushDirectory;
|
|
1959
|
-
pushFile;
|
|
1960
|
-
getArray;
|
|
1961
|
-
groupFiles;
|
|
1962
|
-
resolveSymlink;
|
|
1963
|
-
walkDirectory;
|
|
1964
|
-
callbackInvoker;
|
|
1965
|
-
constructor(root, options, callback$1) {
|
|
1966
|
-
this.isSynchronous = !callback$1;
|
|
1967
|
-
this.callbackInvoker = build$1(options, this.isSynchronous);
|
|
1968
|
-
this.root = normalizePath$1(root, options);
|
|
1969
|
-
this.state = {
|
|
1970
|
-
root: isRootDirectory(this.root) ? this.root : this.root.slice(0, -1),
|
|
1971
|
-
paths: [""].slice(0, 0),
|
|
1972
|
-
groups: [],
|
|
1973
|
-
counts: new Counter(),
|
|
1974
|
-
options,
|
|
1975
|
-
queue: new Queue((error, state) => this.callbackInvoker(state, error, callback$1)),
|
|
1976
|
-
symlinks: /* @__PURE__ */ new Map(),
|
|
1977
|
-
visited: [""].slice(0, 0),
|
|
1978
|
-
controller: new Aborter(),
|
|
1979
|
-
fs: options.fs || nativeFs$1
|
|
1982
|
+
picomatch.test = (input, regex, options, { glob, posix: posix$1 } = {}) => {
|
|
1983
|
+
if (typeof input !== "string") throw new TypeError("Expected input to be a string");
|
|
1984
|
+
if (input === "") return {
|
|
1985
|
+
isMatch: false,
|
|
1986
|
+
output: ""
|
|
1980
1987
|
};
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
}
|
|
1989
|
-
start() {
|
|
1990
|
-
this.pushDirectory(this.root, this.state.paths, this.state.options.filters);
|
|
1991
|
-
this.walkDirectory(this.state, this.root, this.root, this.state.options.maxDepth, this.walk);
|
|
1992
|
-
return this.isSynchronous ? this.callbackInvoker(this.state, null) : null;
|
|
1993
|
-
}
|
|
1994
|
-
walk = (entries, directoryPath, depth) => {
|
|
1995
|
-
const { paths, options: { filters, resolveSymlinks: resolveSymlinks$1, excludeSymlinks, exclude, maxFiles, signal, useRealPaths, pathSeparator }, controller } = this.state;
|
|
1996
|
-
if (controller.aborted || signal && signal.aborted || maxFiles && paths.length > maxFiles) return;
|
|
1997
|
-
const files = this.getArray(this.state.paths);
|
|
1998
|
-
for (let i = 0; i < entries.length; ++i) {
|
|
1999
|
-
const entry = entries[i];
|
|
2000
|
-
if (entry.isFile() || entry.isSymbolicLink() && !resolveSymlinks$1 && !excludeSymlinks) {
|
|
2001
|
-
const filename = this.joinPath(entry.name, directoryPath);
|
|
2002
|
-
this.pushFile(filename, files, this.state.counts, filters);
|
|
2003
|
-
} else if (entry.isDirectory()) {
|
|
2004
|
-
let path$2 = joinDirectoryPath(entry.name, directoryPath, this.state.options.pathSeparator);
|
|
2005
|
-
if (exclude && exclude(entry.name, path$2)) continue;
|
|
2006
|
-
this.pushDirectory(path$2, paths, filters);
|
|
2007
|
-
this.walkDirectory(this.state, path$2, path$2, depth - 1, this.walk);
|
|
2008
|
-
} else if (this.resolveSymlink && entry.isSymbolicLink()) {
|
|
2009
|
-
let path$2 = joinPathWithBasePath(entry.name, directoryPath);
|
|
2010
|
-
this.resolveSymlink(path$2, this.state, (stat, resolvedPath) => {
|
|
2011
|
-
if (stat.isDirectory()) {
|
|
2012
|
-
resolvedPath = normalizePath$1(resolvedPath, this.state.options);
|
|
2013
|
-
if (exclude && exclude(entry.name, useRealPaths ? resolvedPath : path$2 + pathSeparator)) return;
|
|
2014
|
-
this.walkDirectory(this.state, resolvedPath, useRealPaths ? resolvedPath : path$2 + pathSeparator, depth - 1, this.walk);
|
|
2015
|
-
} else {
|
|
2016
|
-
resolvedPath = useRealPaths ? resolvedPath : path$2;
|
|
2017
|
-
const filename = basename(resolvedPath);
|
|
2018
|
-
const directoryPath$1 = normalizePath$1(dirname(resolvedPath), this.state.options);
|
|
2019
|
-
resolvedPath = this.joinPath(filename, directoryPath$1);
|
|
2020
|
-
this.pushFile(resolvedPath, files, this.state.counts, filters);
|
|
2021
|
-
}
|
|
2022
|
-
});
|
|
2023
|
-
}
|
|
1988
|
+
const opts = options || {};
|
|
1989
|
+
const format = opts.format || (posix$1 ? utils.toPosixSlashes : null);
|
|
1990
|
+
let match = input === glob;
|
|
1991
|
+
let output = match && format ? format(input) : input;
|
|
1992
|
+
if (match === false) {
|
|
1993
|
+
output = format ? format(input) : input;
|
|
1994
|
+
match = output === glob;
|
|
2024
1995
|
}
|
|
2025
|
-
|
|
1996
|
+
if (match === false || opts.capture === true) if (opts.matchBase === true || opts.basename === true) match = picomatch.matchBase(input, regex, options, posix$1);
|
|
1997
|
+
else match = regex.exec(output);
|
|
1998
|
+
return {
|
|
1999
|
+
isMatch: Boolean(match),
|
|
2000
|
+
match,
|
|
2001
|
+
output
|
|
2002
|
+
};
|
|
2026
2003
|
};
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
}
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2004
|
+
/**
|
|
2005
|
+
* Match the basename of a filepath.
|
|
2006
|
+
*
|
|
2007
|
+
* ```js
|
|
2008
|
+
* const picomatch = require('picomatch');
|
|
2009
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
2010
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
2011
|
+
* ```
|
|
2012
|
+
* @param {String} `input` String to test.
|
|
2013
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
2014
|
+
* @return {Boolean}
|
|
2015
|
+
* @api public
|
|
2016
|
+
*/
|
|
2017
|
+
picomatch.matchBase = (input, glob, options) => {
|
|
2018
|
+
return (glob instanceof RegExp ? glob : picomatch.makeRe(glob, options)).test(utils.basename(input));
|
|
2019
|
+
};
|
|
2020
|
+
/**
|
|
2021
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
2022
|
+
*
|
|
2023
|
+
* ```js
|
|
2024
|
+
* const picomatch = require('picomatch');
|
|
2025
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
2026
|
+
*
|
|
2027
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
2028
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
2029
|
+
* ```
|
|
2030
|
+
* @param {String|Array} str The string to test.
|
|
2031
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
2032
|
+
* @param {Object} [options] See available [options](#options).
|
|
2033
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
2034
|
+
* @api public
|
|
2035
|
+
*/
|
|
2036
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
2037
|
+
/**
|
|
2038
|
+
* Parse a glob pattern to create the source string for a regular
|
|
2039
|
+
* expression.
|
|
2040
|
+
*
|
|
2041
|
+
* ```js
|
|
2042
|
+
* const picomatch = require('picomatch');
|
|
2043
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
2044
|
+
* ```
|
|
2045
|
+
* @param {String} `pattern`
|
|
2046
|
+
* @param {Object} `options`
|
|
2047
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
2048
|
+
* @api public
|
|
2049
|
+
*/
|
|
2050
|
+
picomatch.parse = (pattern, options) => {
|
|
2051
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch.parse(p, options));
|
|
2052
|
+
return parse(pattern, {
|
|
2053
|
+
...options,
|
|
2054
|
+
fastpaths: false
|
|
2055
|
+
});
|
|
2070
2056
|
};
|
|
2071
|
-
globFunction;
|
|
2072
|
-
constructor(options) {
|
|
2073
|
-
this.options = {
|
|
2074
|
-
...this.options,
|
|
2075
|
-
...options
|
|
2076
|
-
};
|
|
2077
|
-
this.globFunction = this.options.globFunction;
|
|
2078
|
-
}
|
|
2079
|
-
group() {
|
|
2080
|
-
this.options.group = true;
|
|
2081
|
-
return this;
|
|
2082
|
-
}
|
|
2083
|
-
withPathSeparator(separator) {
|
|
2084
|
-
this.options.pathSeparator = separator;
|
|
2085
|
-
return this;
|
|
2086
|
-
}
|
|
2087
|
-
withBasePath() {
|
|
2088
|
-
this.options.includeBasePath = true;
|
|
2089
|
-
return this;
|
|
2090
|
-
}
|
|
2091
|
-
withRelativePaths() {
|
|
2092
|
-
this.options.relativePaths = true;
|
|
2093
|
-
return this;
|
|
2094
|
-
}
|
|
2095
|
-
withDirs() {
|
|
2096
|
-
this.options.includeDirs = true;
|
|
2097
|
-
return this;
|
|
2098
|
-
}
|
|
2099
|
-
withMaxDepth(depth) {
|
|
2100
|
-
this.options.maxDepth = depth;
|
|
2101
|
-
return this;
|
|
2102
|
-
}
|
|
2103
|
-
withMaxFiles(limit) {
|
|
2104
|
-
this.options.maxFiles = limit;
|
|
2105
|
-
return this;
|
|
2106
|
-
}
|
|
2107
|
-
withFullPaths() {
|
|
2108
|
-
this.options.resolvePaths = true;
|
|
2109
|
-
this.options.includeBasePath = true;
|
|
2110
|
-
return this;
|
|
2111
|
-
}
|
|
2112
|
-
withErrors() {
|
|
2113
|
-
this.options.suppressErrors = false;
|
|
2114
|
-
return this;
|
|
2115
|
-
}
|
|
2116
|
-
withSymlinks({ resolvePaths = true } = {}) {
|
|
2117
|
-
this.options.resolveSymlinks = true;
|
|
2118
|
-
this.options.useRealPaths = resolvePaths;
|
|
2119
|
-
return this.withFullPaths();
|
|
2120
|
-
}
|
|
2121
|
-
withAbortSignal(signal) {
|
|
2122
|
-
this.options.signal = signal;
|
|
2123
|
-
return this;
|
|
2124
|
-
}
|
|
2125
|
-
normalize() {
|
|
2126
|
-
this.options.normalizePath = true;
|
|
2127
|
-
return this;
|
|
2128
|
-
}
|
|
2129
|
-
filter(predicate) {
|
|
2130
|
-
this.options.filters.push(predicate);
|
|
2131
|
-
return this;
|
|
2132
|
-
}
|
|
2133
|
-
onlyDirs() {
|
|
2134
|
-
this.options.excludeFiles = true;
|
|
2135
|
-
this.options.includeDirs = true;
|
|
2136
|
-
return this;
|
|
2137
|
-
}
|
|
2138
|
-
exclude(predicate) {
|
|
2139
|
-
this.options.exclude = predicate;
|
|
2140
|
-
return this;
|
|
2141
|
-
}
|
|
2142
|
-
onlyCounts() {
|
|
2143
|
-
this.options.onlyCounts = true;
|
|
2144
|
-
return this;
|
|
2145
|
-
}
|
|
2146
|
-
crawl(root) {
|
|
2147
|
-
return new APIBuilder(root || ".", this.options);
|
|
2148
|
-
}
|
|
2149
|
-
withGlobFunction(fn) {
|
|
2150
|
-
this.globFunction = fn;
|
|
2151
|
-
return this;
|
|
2152
|
-
}
|
|
2153
2057
|
/**
|
|
2154
|
-
*
|
|
2155
|
-
*
|
|
2156
|
-
*
|
|
2058
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
2059
|
+
*
|
|
2060
|
+
* ```js
|
|
2061
|
+
* const picomatch = require('picomatch');
|
|
2062
|
+
* // picomatch.scan(input[, options]);
|
|
2063
|
+
*
|
|
2064
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
2065
|
+
* console.log(result);
|
|
2066
|
+
* { prefix: '!./',
|
|
2067
|
+
* input: '!./foo/*.js',
|
|
2068
|
+
* start: 3,
|
|
2069
|
+
* base: 'foo',
|
|
2070
|
+
* glob: '*.js',
|
|
2071
|
+
* isBrace: false,
|
|
2072
|
+
* isBracket: false,
|
|
2073
|
+
* isGlob: true,
|
|
2074
|
+
* isExtglob: false,
|
|
2075
|
+
* isGlobstar: false,
|
|
2076
|
+
* negated: true }
|
|
2157
2077
|
* ```
|
|
2158
|
-
*
|
|
2078
|
+
* @param {String} `input` Glob pattern to scan.
|
|
2079
|
+
* @param {Object} `options`
|
|
2080
|
+
* @return {Object} Returns an object with
|
|
2081
|
+
* @api public
|
|
2159
2082
|
*/
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2083
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
2084
|
+
/**
|
|
2085
|
+
* Compile a regular expression from the `state` object returned by the
|
|
2086
|
+
* [parse()](#parse) method.
|
|
2087
|
+
*
|
|
2088
|
+
* @param {Object} `state`
|
|
2089
|
+
* @param {Object} `options`
|
|
2090
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
2091
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
2092
|
+
* @return {RegExp}
|
|
2093
|
+
* @api public
|
|
2094
|
+
*/
|
|
2095
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2096
|
+
if (returnOutput === true) return state.output;
|
|
2097
|
+
const opts = options || {};
|
|
2098
|
+
const prepend = opts.contains ? "" : "^";
|
|
2099
|
+
const append = opts.contains ? "" : "$";
|
|
2100
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2101
|
+
if (state && state.negated === true) source = `^(?!${source}).*$`;
|
|
2102
|
+
const regex = picomatch.toRegex(source, options);
|
|
2103
|
+
if (returnState === true) regex.state = state;
|
|
2104
|
+
return regex;
|
|
2105
|
+
};
|
|
2106
|
+
/**
|
|
2107
|
+
* Create a regular expression from a parsed glob pattern.
|
|
2108
|
+
*
|
|
2109
|
+
* ```js
|
|
2110
|
+
* const picomatch = require('picomatch');
|
|
2111
|
+
* const state = picomatch.parse('*.js');
|
|
2112
|
+
* // picomatch.compileRe(state[, options]);
|
|
2113
|
+
*
|
|
2114
|
+
* console.log(picomatch.compileRe(state));
|
|
2115
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2116
|
+
* ```
|
|
2117
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
2118
|
+
* @param {Object} `options`
|
|
2119
|
+
* @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.
|
|
2120
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
2121
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
2122
|
+
* @api public
|
|
2123
|
+
*/
|
|
2124
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2125
|
+
if (!input || typeof input !== "string") throw new TypeError("Expected a non-empty string");
|
|
2126
|
+
let parsed = {
|
|
2127
|
+
negated: false,
|
|
2128
|
+
fastpaths: true
|
|
2165
2129
|
};
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2130
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) parsed.output = parse.fastpaths(input, options);
|
|
2131
|
+
if (!parsed.output) parsed = parse(input, options);
|
|
2132
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
2133
|
+
};
|
|
2134
|
+
/**
|
|
2135
|
+
* Create a regular expression from the given regex source string.
|
|
2136
|
+
*
|
|
2137
|
+
* ```js
|
|
2138
|
+
* const picomatch = require('picomatch');
|
|
2139
|
+
* // picomatch.toRegex(source[, options]);
|
|
2140
|
+
*
|
|
2141
|
+
* const { output } = picomatch.parse('*.js');
|
|
2142
|
+
* console.log(picomatch.toRegex(output));
|
|
2143
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
2144
|
+
* ```
|
|
2145
|
+
* @param {String} `source` Regular expression source string.
|
|
2146
|
+
* @param {Object} `options`
|
|
2147
|
+
* @return {RegExp}
|
|
2148
|
+
* @api public
|
|
2149
|
+
*/
|
|
2150
|
+
picomatch.toRegex = (source, options) => {
|
|
2151
|
+
try {
|
|
2152
|
+
const opts = options || {};
|
|
2153
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2154
|
+
} catch (err) {
|
|
2155
|
+
if (options && options.debug === true) throw err;
|
|
2156
|
+
return /$^/;
|
|
2180
2157
|
}
|
|
2181
|
-
|
|
2182
|
-
|
|
2158
|
+
};
|
|
2159
|
+
/**
|
|
2160
|
+
* Picomatch constants.
|
|
2161
|
+
* @return {Object}
|
|
2162
|
+
*/
|
|
2163
|
+
picomatch.constants = constants;
|
|
2164
|
+
/**
|
|
2165
|
+
* Expose "picomatch"
|
|
2166
|
+
*/
|
|
2167
|
+
module.exports = picomatch;
|
|
2168
|
+
}));
|
|
2169
|
+
|
|
2170
|
+
//#endregion
|
|
2171
|
+
//#region node_modules/.pnpm/picomatch@4.0.3/node_modules/picomatch/index.js
|
|
2172
|
+
var require_picomatch = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
2173
|
+
const pico = require_picomatch$1();
|
|
2174
|
+
const utils = require_utils();
|
|
2175
|
+
function picomatch(glob, options, returnState = false) {
|
|
2176
|
+
if (options && (options.windows === null || options.windows === void 0)) options = {
|
|
2177
|
+
...options,
|
|
2178
|
+
windows: utils.isWindows()
|
|
2179
|
+
};
|
|
2180
|
+
return pico(glob, options, returnState);
|
|
2183
2181
|
}
|
|
2184
|
-
|
|
2182
|
+
Object.assign(picomatch, pico);
|
|
2183
|
+
module.exports = picomatch;
|
|
2184
|
+
}));
|
|
2185
2185
|
|
|
2186
2186
|
//#endregion
|
|
2187
2187
|
//#region node_modules/.pnpm/estree-walker@2.0.2/node_modules/estree-walker/dist/esm/estree-walker.js
|
|
@@ -3856,4 +3856,4 @@ function commonjs(options = {}) {
|
|
|
3856
3856
|
}
|
|
3857
3857
|
|
|
3858
3858
|
//#endregion
|
|
3859
|
-
export { makeLegalIdentifier as a,
|
|
3859
|
+
export { makeLegalIdentifier as a, Builder as c, dataToEsm as i, attachScopes as n, walk as o, createFilter as r, require_picomatch as s, commonjs as t };
|