rollup 4.22.3 → 4.22.5
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/bin/rollup +2 -2
- package/dist/es/getLogFilter.js +2 -2
- package/dist/es/parseAst.js +2 -2
- package/dist/es/rollup.js +2 -2
- package/dist/es/shared/node-entry.js +2030 -1968
- package/dist/es/shared/parseAst.js +2 -2
- package/dist/es/shared/watch.js +8304 -3891
- package/dist/getLogFilter.js +2 -2
- package/dist/loadConfigFile.js +2 -2
- package/dist/parseAst.js +2 -2
- package/dist/rollup.js +2 -2
- package/dist/shared/fsevents-importer.js +2 -2
- package/dist/shared/index.js +8532 -4119
- package/dist/shared/loadConfigFile.js +2 -2
- package/dist/shared/parseAst.js +2 -2
- package/dist/shared/rollup.js +2061 -1999
- package/dist/shared/watch-cli.js +3 -3
- package/dist/shared/watch.js +2 -2
- package/package.json +38 -39
package/dist/shared/rollup.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
@license
|
|
3
|
-
Rollup.js v4.22.
|
|
4
|
-
|
|
3
|
+
Rollup.js v4.22.5
|
|
4
|
+
Fri, 27 Sep 2024 11:47:46 GMT - commit bc7780c322e134492f40a76bf64afe561670425c
|
|
5
5
|
|
|
6
6
|
https://github.com/rollup/rollup
|
|
7
7
|
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
const parseAst_js = require('./parseAst.js');
|
|
13
13
|
const process$1 = require('node:process');
|
|
14
14
|
const tty = require('tty');
|
|
15
|
-
const path
|
|
15
|
+
const path = require('node:path');
|
|
16
16
|
const require$$0 = require('path');
|
|
17
17
|
const native_js = require('../native.js');
|
|
18
18
|
const node_perf_hooks = require('node:perf_hooks');
|
|
@@ -31,7 +31,7 @@ function _interopNamespaceDefault(e) {
|
|
|
31
31
|
|
|
32
32
|
const tty__namespace = /*#__PURE__*/_interopNamespaceDefault(tty);
|
|
33
33
|
|
|
34
|
-
var version = "4.22.
|
|
34
|
+
var version = "4.22.5";
|
|
35
35
|
|
|
36
36
|
function ensureArray$1(items) {
|
|
37
37
|
if (Array.isArray(items)) {
|
|
@@ -199,7 +199,7 @@ function renderNamePattern(pattern, patternName, replacements) {
|
|
|
199
199
|
function makeUnique(name, { [lowercaseBundleKeys]: reservedLowercaseBundleKeys }) {
|
|
200
200
|
if (!reservedLowercaseBundleKeys.has(name.toLowerCase()))
|
|
201
201
|
return name;
|
|
202
|
-
const extension = path
|
|
202
|
+
const extension = path.extname(name);
|
|
203
203
|
name = name.slice(0, Math.max(0, name.length - extension.length));
|
|
204
204
|
let uniqueName, uniqueIndex = 1;
|
|
205
205
|
while (reservedLowercaseBundleKeys.has((uniqueName = name + ++uniqueIndex + extension).toLowerCase()))
|
|
@@ -212,10 +212,10 @@ function generateAssetFileName(name, source, originalFileName, sourceHash, outpu
|
|
|
212
212
|
return makeUnique(renderNamePattern(typeof outputOptions.assetFileNames === 'function'
|
|
213
213
|
? outputOptions.assetFileNames({ name, originalFileName, source, type: 'asset' })
|
|
214
214
|
: outputOptions.assetFileNames, 'output.assetFileNames', {
|
|
215
|
-
ext: () => path
|
|
216
|
-
extname: () => path
|
|
215
|
+
ext: () => path.extname(emittedName).slice(1),
|
|
216
|
+
extname: () => path.extname(emittedName),
|
|
217
217
|
hash: size => sourceHash.slice(0, Math.max(0, size || DEFAULT_HASH_SIZE)),
|
|
218
|
-
name: () => emittedName.slice(0, Math.max(0, emittedName.length - path
|
|
218
|
+
name: () => emittedName.slice(0, Math.max(0, emittedName.length - path.extname(emittedName).length))
|
|
219
219
|
}), bundle);
|
|
220
220
|
}
|
|
221
221
|
function reserveFileNameInBundle(fileName, { bundle }, log) {
|
|
@@ -1963,7 +1963,7 @@ function getRelativePath(from, to) {
|
|
|
1963
1963
|
|
|
1964
1964
|
const toString = Object.prototype.toString;
|
|
1965
1965
|
|
|
1966
|
-
function isObject
|
|
1966
|
+
function isObject(thing) {
|
|
1967
1967
|
return toString.call(thing) === '[object Object]';
|
|
1968
1968
|
}
|
|
1969
1969
|
|
|
@@ -2284,7 +2284,7 @@ class MagicString {
|
|
|
2284
2284
|
indent(indentStr, options) {
|
|
2285
2285
|
const pattern = /^[^\r\n]/gm;
|
|
2286
2286
|
|
|
2287
|
-
if (isObject
|
|
2287
|
+
if (isObject(indentStr)) {
|
|
2288
2288
|
options = indentStr;
|
|
2289
2289
|
indentStr = undefined;
|
|
2290
2290
|
}
|
|
@@ -2961,7 +2961,7 @@ let Bundle$1 = class Bundle {
|
|
|
2961
2961
|
});
|
|
2962
2962
|
}
|
|
2963
2963
|
|
|
2964
|
-
if (!isObject
|
|
2964
|
+
if (!isObject(source) || !source.content) {
|
|
2965
2965
|
throw new Error(
|
|
2966
2966
|
'bundle.addSource() takes an object with a `content` property, which should be an instance of MagicString, and an optional `filename`',
|
|
2967
2967
|
);
|
|
@@ -8638,7 +8638,7 @@ class MetaProperty extends NodeBase {
|
|
|
8638
8638
|
const chunkId = preliminaryChunkId;
|
|
8639
8639
|
if (referenceId) {
|
|
8640
8640
|
const fileName = pluginDriver.getFileName(referenceId);
|
|
8641
|
-
const relativePath = parseAst_js.normalize(path
|
|
8641
|
+
const relativePath = parseAst_js.normalize(path.relative(path.dirname(chunkId), fileName));
|
|
8642
8642
|
const replacement = pluginDriver.hookFirstSync('resolveFileUrl', [
|
|
8643
8643
|
{ chunkId, fileName, format, moduleId, referenceId, relativePath }
|
|
8644
8644
|
]) || relativeUrlMechanisms[format](relativePath);
|
|
@@ -8689,7 +8689,7 @@ const accessedFileUrlGlobals = {
|
|
|
8689
8689
|
umd: ['document', 'require', 'URL']
|
|
8690
8690
|
};
|
|
8691
8691
|
const getResolveUrl = (path, URL = 'URL') => `new ${URL}(${path}).href`;
|
|
8692
|
-
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.src || document.baseURI`);
|
|
8692
|
+
const getRelativeUrlFromDocument = (relativePath, umd = false) => getResolveUrl(`'${escapeId(relativePath)}', ${umd ? `typeof document === 'undefined' ? location.href : ` : ''}document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT' && document.currentScript.src || document.baseURI`);
|
|
8693
8693
|
const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
|
|
8694
8694
|
const urlMechanism = getUrl(chunkId);
|
|
8695
8695
|
return property === null
|
|
@@ -8700,7 +8700,7 @@ const getGenericImportMetaMechanism = (getUrl) => (property, { chunkId }) => {
|
|
|
8700
8700
|
};
|
|
8701
8701
|
const getFileUrlFromFullPath = (path) => `require('u' + 'rl').pathToFileURL(${path}).href`;
|
|
8702
8702
|
const getFileUrlFromRelativePath = (path) => getFileUrlFromFullPath(`__dirname + '/${escapeId(path)}'`);
|
|
8703
|
-
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
|
|
8703
|
+
const getUrlFromDocument = (chunkId, umd = false) => `${umd ? `typeof document === 'undefined' ? location.href : ` : ''}(${DOCUMENT_CURRENT_SCRIPT} && ${DOCUMENT_CURRENT_SCRIPT}.tagName.toUpperCase() === 'SCRIPT' && ${DOCUMENT_CURRENT_SCRIPT}.src || new URL('${escapeId(chunkId)}', document.baseURI).href)`;
|
|
8704
8704
|
const relativeUrlMechanisms = {
|
|
8705
8705
|
amd: relativePath => {
|
|
8706
8706
|
if (relativePath[0] !== '.')
|
|
@@ -9005,7 +9005,7 @@ class ExternalChunk {
|
|
|
9005
9005
|
const { paths } = this.options;
|
|
9006
9006
|
return (this.fileName =
|
|
9007
9007
|
(typeof paths === 'function' ? paths(this.id) : paths[this.id]) ||
|
|
9008
|
-
(this.renormalizeRenderPath ? parseAst_js.normalize(path
|
|
9008
|
+
(this.renormalizeRenderPath ? parseAst_js.normalize(path.relative(this.inputBase, this.id)) : this.id));
|
|
9009
9009
|
}
|
|
9010
9010
|
getImportAttributes(snippets) {
|
|
9011
9011
|
return (this.importAttributes ||= formatAttributes(this.options.format === 'es' &&
|
|
@@ -9523,14 +9523,17 @@ const keypath = (keypath, getPropertyAccess) => keypath.split('.').map(getProper
|
|
|
9523
9523
|
|
|
9524
9524
|
function setupNamespace(name, root, globals, { _, getPropertyAccess, s }, compact, log) {
|
|
9525
9525
|
const parts = name.split('.');
|
|
9526
|
-
// Check if the key
|
|
9527
|
-
const isReserved = parts[0] in
|
|
9526
|
+
// Check if the key exists in the object's prototype.
|
|
9527
|
+
const isReserved = parts[0] in Object.prototype;
|
|
9528
9528
|
if (log && isReserved) {
|
|
9529
9529
|
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logReservedNamespace(parts[0]));
|
|
9530
9530
|
}
|
|
9531
9531
|
parts[0] =
|
|
9532
|
-
(typeof globals === 'function'
|
|
9533
|
-
parts[0]
|
|
9532
|
+
(typeof globals === 'function'
|
|
9533
|
+
? globals(parts[0])
|
|
9534
|
+
: isReserved
|
|
9535
|
+
? parts[0]
|
|
9536
|
+
: globals[parts[0]]) || parts[0];
|
|
9534
9537
|
parts.pop();
|
|
9535
9538
|
let propertyPath = root;
|
|
9536
9539
|
return (parts
|
|
@@ -9542,14 +9545,17 @@ function setupNamespace(name, root, globals, { _, getPropertyAccess, s }, compac
|
|
|
9542
9545
|
}
|
|
9543
9546
|
function assignToDeepVariable(deepName, root, globals, assignment, { _, getPropertyAccess }, log) {
|
|
9544
9547
|
const parts = deepName.split('.');
|
|
9545
|
-
// Check if the key
|
|
9546
|
-
const isReserved = parts[0] in
|
|
9548
|
+
// Check if the key exists in the object's prototype.
|
|
9549
|
+
const isReserved = parts[0] in Object.prototype;
|
|
9547
9550
|
if (log && isReserved) {
|
|
9548
9551
|
log(parseAst_js.LOGLEVEL_WARN, parseAst_js.logReservedNamespace(parts[0]));
|
|
9549
9552
|
}
|
|
9550
9553
|
parts[0] =
|
|
9551
|
-
(typeof globals === 'function'
|
|
9552
|
-
parts[0]
|
|
9554
|
+
(typeof globals === 'function'
|
|
9555
|
+
? globals(parts[0])
|
|
9556
|
+
: isReserved
|
|
9557
|
+
? parts[0]
|
|
9558
|
+
: globals[parts[0]]) || parts[0];
|
|
9553
9559
|
const last = parts.pop();
|
|
9554
9560
|
let propertyPath = root;
|
|
9555
9561
|
let deepAssignment = [
|
|
@@ -9921,2069 +9927,2122 @@ function getAugmentedNamespace(n) {
|
|
|
9921
9927
|
return a;
|
|
9922
9928
|
}
|
|
9923
9929
|
|
|
9924
|
-
var utils
|
|
9930
|
+
var utils = {};
|
|
9925
9931
|
|
|
9926
|
-
|
|
9927
|
-
|
|
9928
|
-
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
9932
|
+
var constants;
|
|
9933
|
+
var hasRequiredConstants;
|
|
9929
9934
|
|
|
9930
|
-
|
|
9931
|
-
|
|
9932
|
-
|
|
9933
|
-
|
|
9934
|
-
const DOT_LITERAL = '\\.';
|
|
9935
|
-
const PLUS_LITERAL = '\\+';
|
|
9936
|
-
const QMARK_LITERAL = '\\?';
|
|
9937
|
-
const SLASH_LITERAL = '\\/';
|
|
9938
|
-
const ONE_CHAR = '(?=.)';
|
|
9939
|
-
const QMARK = '[^/]';
|
|
9940
|
-
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
9941
|
-
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
9942
|
-
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
9943
|
-
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
9944
|
-
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
9945
|
-
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
9946
|
-
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
9947
|
-
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
9948
|
-
const STAR = `${QMARK}*?`;
|
|
9949
|
-
|
|
9950
|
-
const POSIX_CHARS = {
|
|
9951
|
-
DOT_LITERAL,
|
|
9952
|
-
PLUS_LITERAL,
|
|
9953
|
-
QMARK_LITERAL,
|
|
9954
|
-
SLASH_LITERAL,
|
|
9955
|
-
ONE_CHAR,
|
|
9956
|
-
QMARK,
|
|
9957
|
-
END_ANCHOR,
|
|
9958
|
-
DOTS_SLASH,
|
|
9959
|
-
NO_DOT,
|
|
9960
|
-
NO_DOTS,
|
|
9961
|
-
NO_DOT_SLASH,
|
|
9962
|
-
NO_DOTS_SLASH,
|
|
9963
|
-
QMARK_NO_DOT,
|
|
9964
|
-
STAR,
|
|
9965
|
-
START_ANCHOR
|
|
9966
|
-
};
|
|
9967
|
-
|
|
9968
|
-
/**
|
|
9969
|
-
* Windows glob regex
|
|
9970
|
-
*/
|
|
9971
|
-
|
|
9972
|
-
const WINDOWS_CHARS = {
|
|
9973
|
-
...POSIX_CHARS,
|
|
9974
|
-
|
|
9975
|
-
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
9976
|
-
QMARK: WIN_NO_SLASH,
|
|
9977
|
-
STAR: `${WIN_NO_SLASH}*?`,
|
|
9978
|
-
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
9979
|
-
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
9980
|
-
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
9981
|
-
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
9982
|
-
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
9983
|
-
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
9984
|
-
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
9985
|
-
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
9986
|
-
};
|
|
9987
|
-
|
|
9988
|
-
/**
|
|
9989
|
-
* POSIX Bracket Regex
|
|
9990
|
-
*/
|
|
9991
|
-
|
|
9992
|
-
const POSIX_REGEX_SOURCE$1 = {
|
|
9993
|
-
alnum: 'a-zA-Z0-9',
|
|
9994
|
-
alpha: 'a-zA-Z',
|
|
9995
|
-
ascii: '\\x00-\\x7F',
|
|
9996
|
-
blank: ' \\t',
|
|
9997
|
-
cntrl: '\\x00-\\x1F\\x7F',
|
|
9998
|
-
digit: '0-9',
|
|
9999
|
-
graph: '\\x21-\\x7E',
|
|
10000
|
-
lower: 'a-z',
|
|
10001
|
-
print: '\\x20-\\x7E ',
|
|
10002
|
-
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
10003
|
-
space: ' \\t\\r\\n\\v\\f',
|
|
10004
|
-
upper: 'A-Z',
|
|
10005
|
-
word: 'A-Za-z0-9_',
|
|
10006
|
-
xdigit: 'A-Fa-f0-9'
|
|
10007
|
-
};
|
|
10008
|
-
|
|
10009
|
-
var constants$2 = {
|
|
10010
|
-
MAX_LENGTH: 1024 * 64,
|
|
10011
|
-
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
10012
|
-
|
|
10013
|
-
// regular expressions
|
|
10014
|
-
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
10015
|
-
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
10016
|
-
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
10017
|
-
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
10018
|
-
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
10019
|
-
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
10020
|
-
|
|
10021
|
-
// Replace globs with equivalent patterns to reduce parsing time.
|
|
10022
|
-
REPLACEMENTS: {
|
|
10023
|
-
'***': '*',
|
|
10024
|
-
'**/**': '**',
|
|
10025
|
-
'**/**/**': '**'
|
|
10026
|
-
},
|
|
10027
|
-
|
|
10028
|
-
// Digits
|
|
10029
|
-
CHAR_0: 48, /* 0 */
|
|
10030
|
-
CHAR_9: 57, /* 9 */
|
|
10031
|
-
|
|
10032
|
-
// Alphabet chars.
|
|
10033
|
-
CHAR_UPPERCASE_A: 65, /* A */
|
|
10034
|
-
CHAR_LOWERCASE_A: 97, /* a */
|
|
10035
|
-
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
10036
|
-
CHAR_LOWERCASE_Z: 122, /* z */
|
|
10037
|
-
|
|
10038
|
-
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
10039
|
-
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
10040
|
-
|
|
10041
|
-
CHAR_ASTERISK: 42, /* * */
|
|
10042
|
-
|
|
10043
|
-
// Non-alphabetic chars.
|
|
10044
|
-
CHAR_AMPERSAND: 38, /* & */
|
|
10045
|
-
CHAR_AT: 64, /* @ */
|
|
10046
|
-
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
10047
|
-
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
10048
|
-
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
10049
|
-
CHAR_COLON: 58, /* : */
|
|
10050
|
-
CHAR_COMMA: 44, /* , */
|
|
10051
|
-
CHAR_DOT: 46, /* . */
|
|
10052
|
-
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
10053
|
-
CHAR_EQUAL: 61, /* = */
|
|
10054
|
-
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
10055
|
-
CHAR_FORM_FEED: 12, /* \f */
|
|
10056
|
-
CHAR_FORWARD_SLASH: 47, /* / */
|
|
10057
|
-
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
10058
|
-
CHAR_HASH: 35, /* # */
|
|
10059
|
-
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
10060
|
-
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
10061
|
-
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
10062
|
-
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
10063
|
-
CHAR_LINE_FEED: 10, /* \n */
|
|
10064
|
-
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
10065
|
-
CHAR_PERCENT: 37, /* % */
|
|
10066
|
-
CHAR_PLUS: 43, /* + */
|
|
10067
|
-
CHAR_QUESTION_MARK: 63, /* ? */
|
|
10068
|
-
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
10069
|
-
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
10070
|
-
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
10071
|
-
CHAR_SEMICOLON: 59, /* ; */
|
|
10072
|
-
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
10073
|
-
CHAR_SPACE: 32, /* */
|
|
10074
|
-
CHAR_TAB: 9, /* \t */
|
|
10075
|
-
CHAR_UNDERSCORE: 95, /* _ */
|
|
10076
|
-
CHAR_VERTICAL_LINE: 124, /* | */
|
|
10077
|
-
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
10078
|
-
|
|
10079
|
-
SEP: path$1.sep,
|
|
10080
|
-
|
|
10081
|
-
/**
|
|
10082
|
-
* Create EXTGLOB_CHARS
|
|
10083
|
-
*/
|
|
10084
|
-
|
|
10085
|
-
extglobChars(chars) {
|
|
10086
|
-
return {
|
|
10087
|
-
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
10088
|
-
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
10089
|
-
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
10090
|
-
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
10091
|
-
'@': { type: 'at', open: '(?:', close: ')' }
|
|
10092
|
-
};
|
|
10093
|
-
},
|
|
10094
|
-
|
|
10095
|
-
/**
|
|
10096
|
-
* Create GLOB_CHARS
|
|
10097
|
-
*/
|
|
10098
|
-
|
|
10099
|
-
globChars(win32) {
|
|
10100
|
-
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
10101
|
-
}
|
|
10102
|
-
};
|
|
10103
|
-
|
|
10104
|
-
(function (exports) {
|
|
9935
|
+
function requireConstants () {
|
|
9936
|
+
if (hasRequiredConstants) return constants;
|
|
9937
|
+
hasRequiredConstants = 1;
|
|
10105
9938
|
|
|
10106
9939
|
const path = require$$0;
|
|
10107
|
-
const
|
|
10108
|
-
const {
|
|
10109
|
-
|
|
10110
|
-
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
9940
|
+
const WIN_SLASH = '\\\\/';
|
|
9941
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
9942
|
+
|
|
9943
|
+
/**
|
|
9944
|
+
* Posix glob regex
|
|
9945
|
+
*/
|
|
9946
|
+
|
|
9947
|
+
const DOT_LITERAL = '\\.';
|
|
9948
|
+
const PLUS_LITERAL = '\\+';
|
|
9949
|
+
const QMARK_LITERAL = '\\?';
|
|
9950
|
+
const SLASH_LITERAL = '\\/';
|
|
9951
|
+
const ONE_CHAR = '(?=.)';
|
|
9952
|
+
const QMARK = '[^/]';
|
|
9953
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
9954
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
9955
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
9956
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
9957
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
9958
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
9959
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
9960
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
9961
|
+
const STAR = `${QMARK}*?`;
|
|
9962
|
+
|
|
9963
|
+
const POSIX_CHARS = {
|
|
9964
|
+
DOT_LITERAL,
|
|
9965
|
+
PLUS_LITERAL,
|
|
9966
|
+
QMARK_LITERAL,
|
|
9967
|
+
SLASH_LITERAL,
|
|
9968
|
+
ONE_CHAR,
|
|
9969
|
+
QMARK,
|
|
9970
|
+
END_ANCHOR,
|
|
9971
|
+
DOTS_SLASH,
|
|
9972
|
+
NO_DOT,
|
|
9973
|
+
NO_DOTS,
|
|
9974
|
+
NO_DOT_SLASH,
|
|
9975
|
+
NO_DOTS_SLASH,
|
|
9976
|
+
QMARK_NO_DOT,
|
|
9977
|
+
STAR,
|
|
9978
|
+
START_ANCHOR
|
|
10125
9979
|
};
|
|
10126
9980
|
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
9981
|
+
/**
|
|
9982
|
+
* Windows glob regex
|
|
9983
|
+
*/
|
|
9984
|
+
|
|
9985
|
+
const WINDOWS_CHARS = {
|
|
9986
|
+
...POSIX_CHARS,
|
|
9987
|
+
|
|
9988
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
9989
|
+
QMARK: WIN_NO_SLASH,
|
|
9990
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
9991
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
9992
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
9993
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
9994
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
9995
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
9996
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
9997
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
9998
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
10133
9999
|
};
|
|
10134
10000
|
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10001
|
+
/**
|
|
10002
|
+
* POSIX Bracket Regex
|
|
10003
|
+
*/
|
|
10004
|
+
|
|
10005
|
+
const POSIX_REGEX_SOURCE = {
|
|
10006
|
+
alnum: 'a-zA-Z0-9',
|
|
10007
|
+
alpha: 'a-zA-Z',
|
|
10008
|
+
ascii: '\\x00-\\x7F',
|
|
10009
|
+
blank: ' \\t',
|
|
10010
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
10011
|
+
digit: '0-9',
|
|
10012
|
+
graph: '\\x21-\\x7E',
|
|
10013
|
+
lower: 'a-z',
|
|
10014
|
+
print: '\\x20-\\x7E ',
|
|
10015
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
10016
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
10017
|
+
upper: 'A-Z',
|
|
10018
|
+
word: 'A-Za-z0-9_',
|
|
10019
|
+
xdigit: 'A-Fa-f0-9'
|
|
10140
10020
|
};
|
|
10141
10021
|
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
|
|
10145
|
-
|
|
10146
|
-
|
|
10147
|
-
|
|
10148
|
-
|
|
10149
|
-
|
|
10150
|
-
|
|
10151
|
-
|
|
10152
|
-
|
|
10153
|
-
|
|
10022
|
+
constants = {
|
|
10023
|
+
MAX_LENGTH: 1024 * 64,
|
|
10024
|
+
POSIX_REGEX_SOURCE,
|
|
10025
|
+
|
|
10026
|
+
// regular expressions
|
|
10027
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
10028
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
10029
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
10030
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
10031
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
10032
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
10033
|
+
|
|
10034
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
10035
|
+
REPLACEMENTS: {
|
|
10036
|
+
'***': '*',
|
|
10037
|
+
'**/**': '**',
|
|
10038
|
+
'**/**/**': '**'
|
|
10039
|
+
},
|
|
10040
|
+
|
|
10041
|
+
// Digits
|
|
10042
|
+
CHAR_0: 48, /* 0 */
|
|
10043
|
+
CHAR_9: 57, /* 9 */
|
|
10044
|
+
|
|
10045
|
+
// Alphabet chars.
|
|
10046
|
+
CHAR_UPPERCASE_A: 65, /* A */
|
|
10047
|
+
CHAR_LOWERCASE_A: 97, /* a */
|
|
10048
|
+
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
10049
|
+
CHAR_LOWERCASE_Z: 122, /* z */
|
|
10050
|
+
|
|
10051
|
+
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
10052
|
+
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
10053
|
+
|
|
10054
|
+
CHAR_ASTERISK: 42, /* * */
|
|
10055
|
+
|
|
10056
|
+
// Non-alphabetic chars.
|
|
10057
|
+
CHAR_AMPERSAND: 38, /* & */
|
|
10058
|
+
CHAR_AT: 64, /* @ */
|
|
10059
|
+
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
10060
|
+
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
10061
|
+
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
10062
|
+
CHAR_COLON: 58, /* : */
|
|
10063
|
+
CHAR_COMMA: 44, /* , */
|
|
10064
|
+
CHAR_DOT: 46, /* . */
|
|
10065
|
+
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
10066
|
+
CHAR_EQUAL: 61, /* = */
|
|
10067
|
+
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
10068
|
+
CHAR_FORM_FEED: 12, /* \f */
|
|
10069
|
+
CHAR_FORWARD_SLASH: 47, /* / */
|
|
10070
|
+
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
10071
|
+
CHAR_HASH: 35, /* # */
|
|
10072
|
+
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
10073
|
+
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
10074
|
+
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
10075
|
+
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
10076
|
+
CHAR_LINE_FEED: 10, /* \n */
|
|
10077
|
+
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
10078
|
+
CHAR_PERCENT: 37, /* % */
|
|
10079
|
+
CHAR_PLUS: 43, /* + */
|
|
10080
|
+
CHAR_QUESTION_MARK: 63, /* ? */
|
|
10081
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
10082
|
+
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
10083
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
10084
|
+
CHAR_SEMICOLON: 59, /* ; */
|
|
10085
|
+
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
10086
|
+
CHAR_SPACE: 32, /* */
|
|
10087
|
+
CHAR_TAB: 9, /* \t */
|
|
10088
|
+
CHAR_UNDERSCORE: 95, /* _ */
|
|
10089
|
+
CHAR_VERTICAL_LINE: 124, /* | */
|
|
10090
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
10091
|
+
|
|
10092
|
+
SEP: path.sep,
|
|
10093
|
+
|
|
10094
|
+
/**
|
|
10095
|
+
* Create EXTGLOB_CHARS
|
|
10096
|
+
*/
|
|
10097
|
+
|
|
10098
|
+
extglobChars(chars) {
|
|
10099
|
+
return {
|
|
10100
|
+
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
10101
|
+
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
10102
|
+
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
10103
|
+
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
10104
|
+
'@': { type: 'at', open: '(?:', close: ')' }
|
|
10105
|
+
};
|
|
10106
|
+
},
|
|
10107
|
+
|
|
10108
|
+
/**
|
|
10109
|
+
* Create GLOB_CHARS
|
|
10110
|
+
*/
|
|
10111
|
+
|
|
10112
|
+
globChars(win32) {
|
|
10113
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
10154
10114
|
}
|
|
10155
|
-
return output;
|
|
10156
10115
|
};
|
|
10116
|
+
return constants;
|
|
10117
|
+
}
|
|
10118
|
+
|
|
10119
|
+
var hasRequiredUtils;
|
|
10120
|
+
|
|
10121
|
+
function requireUtils () {
|
|
10122
|
+
if (hasRequiredUtils) return utils;
|
|
10123
|
+
hasRequiredUtils = 1;
|
|
10124
|
+
(function (exports) {
|
|
10125
|
+
|
|
10126
|
+
const path = require$$0;
|
|
10127
|
+
const win32 = process.platform === 'win32';
|
|
10128
|
+
const {
|
|
10129
|
+
REGEX_BACKSLASH,
|
|
10130
|
+
REGEX_REMOVE_BACKSLASH,
|
|
10131
|
+
REGEX_SPECIAL_CHARS,
|
|
10132
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
10133
|
+
} = /*@__PURE__*/ requireConstants();
|
|
10134
|
+
|
|
10135
|
+
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
10136
|
+
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
10137
|
+
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
10138
|
+
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
10139
|
+
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
10140
|
+
|
|
10141
|
+
exports.removeBackslashes = str => {
|
|
10142
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
10143
|
+
return match === '\\' ? '' : match;
|
|
10144
|
+
});
|
|
10145
|
+
};
|
|
10157
10146
|
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10164
|
-
|
|
10165
|
-
}
|
|
10166
|
-
return output;
|
|
10167
|
-
};
|
|
10168
|
-
} (utils$3));
|
|
10169
|
-
|
|
10170
|
-
const utils$2 = utils$3;
|
|
10171
|
-
const {
|
|
10172
|
-
CHAR_ASTERISK, /* * */
|
|
10173
|
-
CHAR_AT, /* @ */
|
|
10174
|
-
CHAR_BACKWARD_SLASH, /* \ */
|
|
10175
|
-
CHAR_COMMA, /* , */
|
|
10176
|
-
CHAR_DOT, /* . */
|
|
10177
|
-
CHAR_EXCLAMATION_MARK, /* ! */
|
|
10178
|
-
CHAR_FORWARD_SLASH, /* / */
|
|
10179
|
-
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
10180
|
-
CHAR_LEFT_PARENTHESES, /* ( */
|
|
10181
|
-
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
10182
|
-
CHAR_PLUS, /* + */
|
|
10183
|
-
CHAR_QUESTION_MARK, /* ? */
|
|
10184
|
-
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
10185
|
-
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
10186
|
-
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
10187
|
-
} = constants$2;
|
|
10188
|
-
|
|
10189
|
-
const isPathSeparator = code => {
|
|
10190
|
-
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
10191
|
-
};
|
|
10192
|
-
|
|
10193
|
-
const depth = token => {
|
|
10194
|
-
if (token.isPrefix !== true) {
|
|
10195
|
-
token.depth = token.isGlobstar ? Infinity : 1;
|
|
10196
|
-
}
|
|
10197
|
-
};
|
|
10198
|
-
|
|
10199
|
-
/**
|
|
10200
|
-
* Quickly scans a glob pattern and returns an object with a handful of
|
|
10201
|
-
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
10202
|
-
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
10203
|
-
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
10204
|
-
*
|
|
10205
|
-
* ```js
|
|
10206
|
-
* const pm = require('picomatch');
|
|
10207
|
-
* console.log(pm.scan('foo/bar/*.js'));
|
|
10208
|
-
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
10209
|
-
* ```
|
|
10210
|
-
* @param {String} `str`
|
|
10211
|
-
* @param {Object} `options`
|
|
10212
|
-
* @return {Object} Returns an object with tokens and regex source string.
|
|
10213
|
-
* @api public
|
|
10214
|
-
*/
|
|
10215
|
-
|
|
10216
|
-
const scan$1 = (input, options) => {
|
|
10217
|
-
const opts = options || {};
|
|
10218
|
-
|
|
10219
|
-
const length = input.length - 1;
|
|
10220
|
-
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
10221
|
-
const slashes = [];
|
|
10222
|
-
const tokens = [];
|
|
10223
|
-
const parts = [];
|
|
10224
|
-
|
|
10225
|
-
let str = input;
|
|
10226
|
-
let index = -1;
|
|
10227
|
-
let start = 0;
|
|
10228
|
-
let lastIndex = 0;
|
|
10229
|
-
let isBrace = false;
|
|
10230
|
-
let isBracket = false;
|
|
10231
|
-
let isGlob = false;
|
|
10232
|
-
let isExtglob = false;
|
|
10233
|
-
let isGlobstar = false;
|
|
10234
|
-
let braceEscaped = false;
|
|
10235
|
-
let backslashes = false;
|
|
10236
|
-
let negated = false;
|
|
10237
|
-
let negatedExtglob = false;
|
|
10238
|
-
let finished = false;
|
|
10239
|
-
let braces = 0;
|
|
10240
|
-
let prev;
|
|
10241
|
-
let code;
|
|
10242
|
-
let token = { value: '', depth: 0, isGlob: false };
|
|
10243
|
-
|
|
10244
|
-
const eos = () => index >= length;
|
|
10245
|
-
const peek = () => str.charCodeAt(index + 1);
|
|
10246
|
-
const advance = () => {
|
|
10247
|
-
prev = code;
|
|
10248
|
-
return str.charCodeAt(++index);
|
|
10249
|
-
};
|
|
10250
|
-
|
|
10251
|
-
while (index < length) {
|
|
10252
|
-
code = advance();
|
|
10253
|
-
let next;
|
|
10254
|
-
|
|
10255
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
10256
|
-
backslashes = token.backslashes = true;
|
|
10257
|
-
code = advance();
|
|
10258
|
-
|
|
10259
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
10260
|
-
braceEscaped = true;
|
|
10261
|
-
}
|
|
10262
|
-
continue;
|
|
10263
|
-
}
|
|
10264
|
-
|
|
10265
|
-
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
10266
|
-
braces++;
|
|
10267
|
-
|
|
10268
|
-
while (eos() !== true && (code = advance())) {
|
|
10269
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
10270
|
-
backslashes = token.backslashes = true;
|
|
10271
|
-
advance();
|
|
10272
|
-
continue;
|
|
10273
|
-
}
|
|
10274
|
-
|
|
10275
|
-
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
10276
|
-
braces++;
|
|
10277
|
-
continue;
|
|
10278
|
-
}
|
|
10279
|
-
|
|
10280
|
-
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
10281
|
-
isBrace = token.isBrace = true;
|
|
10282
|
-
isGlob = token.isGlob = true;
|
|
10283
|
-
finished = true;
|
|
10284
|
-
|
|
10285
|
-
if (scanToEnd === true) {
|
|
10286
|
-
continue;
|
|
10287
|
-
}
|
|
10288
|
-
|
|
10289
|
-
break;
|
|
10290
|
-
}
|
|
10291
|
-
|
|
10292
|
-
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
10293
|
-
isBrace = token.isBrace = true;
|
|
10294
|
-
isGlob = token.isGlob = true;
|
|
10295
|
-
finished = true;
|
|
10296
|
-
|
|
10297
|
-
if (scanToEnd === true) {
|
|
10298
|
-
continue;
|
|
10299
|
-
}
|
|
10300
|
-
|
|
10301
|
-
break;
|
|
10302
|
-
}
|
|
10303
|
-
|
|
10304
|
-
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
10305
|
-
braces--;
|
|
10306
|
-
|
|
10307
|
-
if (braces === 0) {
|
|
10308
|
-
braceEscaped = false;
|
|
10309
|
-
isBrace = token.isBrace = true;
|
|
10310
|
-
finished = true;
|
|
10311
|
-
break;
|
|
10312
|
-
}
|
|
10313
|
-
}
|
|
10314
|
-
}
|
|
10315
|
-
|
|
10316
|
-
if (scanToEnd === true) {
|
|
10317
|
-
continue;
|
|
10318
|
-
}
|
|
10319
|
-
|
|
10320
|
-
break;
|
|
10321
|
-
}
|
|
10322
|
-
|
|
10323
|
-
if (code === CHAR_FORWARD_SLASH) {
|
|
10324
|
-
slashes.push(index);
|
|
10325
|
-
tokens.push(token);
|
|
10326
|
-
token = { value: '', depth: 0, isGlob: false };
|
|
10327
|
-
|
|
10328
|
-
if (finished === true) continue;
|
|
10329
|
-
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
10330
|
-
start += 2;
|
|
10331
|
-
continue;
|
|
10332
|
-
}
|
|
10333
|
-
|
|
10334
|
-
lastIndex = index + 1;
|
|
10335
|
-
continue;
|
|
10336
|
-
}
|
|
10337
|
-
|
|
10338
|
-
if (opts.noext !== true) {
|
|
10339
|
-
const isExtglobChar = code === CHAR_PLUS
|
|
10340
|
-
|| code === CHAR_AT
|
|
10341
|
-
|| code === CHAR_ASTERISK
|
|
10342
|
-
|| code === CHAR_QUESTION_MARK
|
|
10343
|
-
|| code === CHAR_EXCLAMATION_MARK;
|
|
10344
|
-
|
|
10345
|
-
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
10346
|
-
isGlob = token.isGlob = true;
|
|
10347
|
-
isExtglob = token.isExtglob = true;
|
|
10348
|
-
finished = true;
|
|
10349
|
-
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
10350
|
-
negatedExtglob = true;
|
|
10351
|
-
}
|
|
10352
|
-
|
|
10353
|
-
if (scanToEnd === true) {
|
|
10354
|
-
while (eos() !== true && (code = advance())) {
|
|
10355
|
-
if (code === CHAR_BACKWARD_SLASH) {
|
|
10356
|
-
backslashes = token.backslashes = true;
|
|
10357
|
-
code = advance();
|
|
10358
|
-
continue;
|
|
10359
|
-
}
|
|
10360
|
-
|
|
10361
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
10362
|
-
isGlob = token.isGlob = true;
|
|
10363
|
-
finished = true;
|
|
10364
|
-
break;
|
|
10365
|
-
}
|
|
10366
|
-
}
|
|
10367
|
-
continue;
|
|
10368
|
-
}
|
|
10369
|
-
break;
|
|
10370
|
-
}
|
|
10371
|
-
}
|
|
10372
|
-
|
|
10373
|
-
if (code === CHAR_ASTERISK) {
|
|
10374
|
-
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
10375
|
-
isGlob = token.isGlob = true;
|
|
10376
|
-
finished = true;
|
|
10377
|
-
|
|
10378
|
-
if (scanToEnd === true) {
|
|
10379
|
-
continue;
|
|
10380
|
-
}
|
|
10381
|
-
break;
|
|
10382
|
-
}
|
|
10383
|
-
|
|
10384
|
-
if (code === CHAR_QUESTION_MARK) {
|
|
10385
|
-
isGlob = token.isGlob = true;
|
|
10386
|
-
finished = true;
|
|
10387
|
-
|
|
10388
|
-
if (scanToEnd === true) {
|
|
10389
|
-
continue;
|
|
10390
|
-
}
|
|
10391
|
-
break;
|
|
10392
|
-
}
|
|
10393
|
-
|
|
10394
|
-
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
10395
|
-
while (eos() !== true && (next = advance())) {
|
|
10396
|
-
if (next === CHAR_BACKWARD_SLASH) {
|
|
10397
|
-
backslashes = token.backslashes = true;
|
|
10398
|
-
advance();
|
|
10399
|
-
continue;
|
|
10400
|
-
}
|
|
10401
|
-
|
|
10402
|
-
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
10403
|
-
isBracket = token.isBracket = true;
|
|
10404
|
-
isGlob = token.isGlob = true;
|
|
10405
|
-
finished = true;
|
|
10406
|
-
break;
|
|
10407
|
-
}
|
|
10408
|
-
}
|
|
10409
|
-
|
|
10410
|
-
if (scanToEnd === true) {
|
|
10411
|
-
continue;
|
|
10412
|
-
}
|
|
10413
|
-
|
|
10414
|
-
break;
|
|
10415
|
-
}
|
|
10416
|
-
|
|
10417
|
-
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
10418
|
-
negated = token.negated = true;
|
|
10419
|
-
start++;
|
|
10420
|
-
continue;
|
|
10421
|
-
}
|
|
10422
|
-
|
|
10423
|
-
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
10424
|
-
isGlob = token.isGlob = true;
|
|
10425
|
-
|
|
10426
|
-
if (scanToEnd === true) {
|
|
10427
|
-
while (eos() !== true && (code = advance())) {
|
|
10428
|
-
if (code === CHAR_LEFT_PARENTHESES) {
|
|
10429
|
-
backslashes = token.backslashes = true;
|
|
10430
|
-
code = advance();
|
|
10431
|
-
continue;
|
|
10432
|
-
}
|
|
10433
|
-
|
|
10434
|
-
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
10435
|
-
finished = true;
|
|
10436
|
-
break;
|
|
10437
|
-
}
|
|
10438
|
-
}
|
|
10439
|
-
continue;
|
|
10440
|
-
}
|
|
10441
|
-
break;
|
|
10442
|
-
}
|
|
10443
|
-
|
|
10444
|
-
if (isGlob === true) {
|
|
10445
|
-
finished = true;
|
|
10446
|
-
|
|
10447
|
-
if (scanToEnd === true) {
|
|
10448
|
-
continue;
|
|
10449
|
-
}
|
|
10450
|
-
|
|
10451
|
-
break;
|
|
10452
|
-
}
|
|
10453
|
-
}
|
|
10454
|
-
|
|
10455
|
-
if (opts.noext === true) {
|
|
10456
|
-
isExtglob = false;
|
|
10457
|
-
isGlob = false;
|
|
10458
|
-
}
|
|
10459
|
-
|
|
10460
|
-
let base = str;
|
|
10461
|
-
let prefix = '';
|
|
10462
|
-
let glob = '';
|
|
10463
|
-
|
|
10464
|
-
if (start > 0) {
|
|
10465
|
-
prefix = str.slice(0, start);
|
|
10466
|
-
str = str.slice(start);
|
|
10467
|
-
lastIndex -= start;
|
|
10468
|
-
}
|
|
10469
|
-
|
|
10470
|
-
if (base && isGlob === true && lastIndex > 0) {
|
|
10471
|
-
base = str.slice(0, lastIndex);
|
|
10472
|
-
glob = str.slice(lastIndex);
|
|
10473
|
-
} else if (isGlob === true) {
|
|
10474
|
-
base = '';
|
|
10475
|
-
glob = str;
|
|
10476
|
-
} else {
|
|
10477
|
-
base = str;
|
|
10478
|
-
}
|
|
10479
|
-
|
|
10480
|
-
if (base && base !== '' && base !== '/' && base !== str) {
|
|
10481
|
-
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
10482
|
-
base = base.slice(0, -1);
|
|
10483
|
-
}
|
|
10484
|
-
}
|
|
10485
|
-
|
|
10486
|
-
if (opts.unescape === true) {
|
|
10487
|
-
if (glob) glob = utils$2.removeBackslashes(glob);
|
|
10488
|
-
|
|
10489
|
-
if (base && backslashes === true) {
|
|
10490
|
-
base = utils$2.removeBackslashes(base);
|
|
10491
|
-
}
|
|
10492
|
-
}
|
|
10493
|
-
|
|
10494
|
-
const state = {
|
|
10495
|
-
prefix,
|
|
10496
|
-
input,
|
|
10497
|
-
start,
|
|
10498
|
-
base,
|
|
10499
|
-
glob,
|
|
10500
|
-
isBrace,
|
|
10501
|
-
isBracket,
|
|
10502
|
-
isGlob,
|
|
10503
|
-
isExtglob,
|
|
10504
|
-
isGlobstar,
|
|
10505
|
-
negated,
|
|
10506
|
-
negatedExtglob
|
|
10507
|
-
};
|
|
10508
|
-
|
|
10509
|
-
if (opts.tokens === true) {
|
|
10510
|
-
state.maxDepth = 0;
|
|
10511
|
-
if (!isPathSeparator(code)) {
|
|
10512
|
-
tokens.push(token);
|
|
10513
|
-
}
|
|
10514
|
-
state.tokens = tokens;
|
|
10515
|
-
}
|
|
10516
|
-
|
|
10517
|
-
if (opts.parts === true || opts.tokens === true) {
|
|
10518
|
-
let prevIndex;
|
|
10519
|
-
|
|
10520
|
-
for (let idx = 0; idx < slashes.length; idx++) {
|
|
10521
|
-
const n = prevIndex ? prevIndex + 1 : start;
|
|
10522
|
-
const i = slashes[idx];
|
|
10523
|
-
const value = input.slice(n, i);
|
|
10524
|
-
if (opts.tokens) {
|
|
10525
|
-
if (idx === 0 && start !== 0) {
|
|
10526
|
-
tokens[idx].isPrefix = true;
|
|
10527
|
-
tokens[idx].value = prefix;
|
|
10528
|
-
} else {
|
|
10529
|
-
tokens[idx].value = value;
|
|
10530
|
-
}
|
|
10531
|
-
depth(tokens[idx]);
|
|
10532
|
-
state.maxDepth += tokens[idx].depth;
|
|
10533
|
-
}
|
|
10534
|
-
if (idx !== 0 || value !== '') {
|
|
10535
|
-
parts.push(value);
|
|
10536
|
-
}
|
|
10537
|
-
prevIndex = i;
|
|
10538
|
-
}
|
|
10539
|
-
|
|
10540
|
-
if (prevIndex && prevIndex + 1 < input.length) {
|
|
10541
|
-
const value = input.slice(prevIndex + 1);
|
|
10542
|
-
parts.push(value);
|
|
10543
|
-
|
|
10544
|
-
if (opts.tokens) {
|
|
10545
|
-
tokens[tokens.length - 1].value = value;
|
|
10546
|
-
depth(tokens[tokens.length - 1]);
|
|
10547
|
-
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
10548
|
-
}
|
|
10549
|
-
}
|
|
10550
|
-
|
|
10551
|
-
state.slashes = slashes;
|
|
10552
|
-
state.parts = parts;
|
|
10553
|
-
}
|
|
10554
|
-
|
|
10555
|
-
return state;
|
|
10556
|
-
};
|
|
10557
|
-
|
|
10558
|
-
var scan_1 = scan$1;
|
|
10559
|
-
|
|
10560
|
-
const constants$1 = constants$2;
|
|
10561
|
-
const utils$1 = utils$3;
|
|
10562
|
-
|
|
10563
|
-
/**
|
|
10564
|
-
* Constants
|
|
10565
|
-
*/
|
|
10566
|
-
|
|
10567
|
-
const {
|
|
10568
|
-
MAX_LENGTH,
|
|
10569
|
-
POSIX_REGEX_SOURCE,
|
|
10570
|
-
REGEX_NON_SPECIAL_CHARS,
|
|
10571
|
-
REGEX_SPECIAL_CHARS_BACKREF,
|
|
10572
|
-
REPLACEMENTS
|
|
10573
|
-
} = constants$1;
|
|
10574
|
-
|
|
10575
|
-
/**
|
|
10576
|
-
* Helpers
|
|
10577
|
-
*/
|
|
10578
|
-
|
|
10579
|
-
const expandRange = (args, options) => {
|
|
10580
|
-
if (typeof options.expandRange === 'function') {
|
|
10581
|
-
return options.expandRange(...args, options);
|
|
10582
|
-
}
|
|
10583
|
-
|
|
10584
|
-
args.sort();
|
|
10585
|
-
const value = `[${args.join('-')}]`;
|
|
10586
|
-
|
|
10587
|
-
return value;
|
|
10588
|
-
};
|
|
10589
|
-
|
|
10590
|
-
/**
|
|
10591
|
-
* Create the message for a syntax error
|
|
10592
|
-
*/
|
|
10593
|
-
|
|
10594
|
-
const syntaxError = (type, char) => {
|
|
10595
|
-
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
10596
|
-
};
|
|
10597
|
-
|
|
10598
|
-
/**
|
|
10599
|
-
* Parse the given input string.
|
|
10600
|
-
* @param {String} input
|
|
10601
|
-
* @param {Object} options
|
|
10602
|
-
* @return {Object}
|
|
10603
|
-
*/
|
|
10604
|
-
|
|
10605
|
-
const parse$1 = (input, options) => {
|
|
10606
|
-
if (typeof input !== 'string') {
|
|
10607
|
-
throw new TypeError('Expected a string');
|
|
10608
|
-
}
|
|
10609
|
-
|
|
10610
|
-
input = REPLACEMENTS[input] || input;
|
|
10611
|
-
|
|
10612
|
-
const opts = { ...options };
|
|
10613
|
-
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
10614
|
-
|
|
10615
|
-
let len = input.length;
|
|
10616
|
-
if (len > max) {
|
|
10617
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
10618
|
-
}
|
|
10619
|
-
|
|
10620
|
-
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
10621
|
-
const tokens = [bos];
|
|
10622
|
-
|
|
10623
|
-
const capture = opts.capture ? '' : '?:';
|
|
10624
|
-
const win32 = utils$1.isWindows(options);
|
|
10625
|
-
|
|
10626
|
-
// create constants based on platform, for windows or posix
|
|
10627
|
-
const PLATFORM_CHARS = constants$1.globChars(win32);
|
|
10628
|
-
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
10629
|
-
|
|
10630
|
-
const {
|
|
10631
|
-
DOT_LITERAL,
|
|
10632
|
-
PLUS_LITERAL,
|
|
10633
|
-
SLASH_LITERAL,
|
|
10634
|
-
ONE_CHAR,
|
|
10635
|
-
DOTS_SLASH,
|
|
10636
|
-
NO_DOT,
|
|
10637
|
-
NO_DOT_SLASH,
|
|
10638
|
-
NO_DOTS_SLASH,
|
|
10639
|
-
QMARK,
|
|
10640
|
-
QMARK_NO_DOT,
|
|
10641
|
-
STAR,
|
|
10642
|
-
START_ANCHOR
|
|
10643
|
-
} = PLATFORM_CHARS;
|
|
10644
|
-
|
|
10645
|
-
const globstar = opts => {
|
|
10646
|
-
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
10647
|
-
};
|
|
10648
|
-
|
|
10649
|
-
const nodot = opts.dot ? '' : NO_DOT;
|
|
10650
|
-
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
10651
|
-
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
10652
|
-
|
|
10653
|
-
if (opts.capture) {
|
|
10654
|
-
star = `(${star})`;
|
|
10655
|
-
}
|
|
10656
|
-
|
|
10657
|
-
// minimatch options support
|
|
10658
|
-
if (typeof opts.noext === 'boolean') {
|
|
10659
|
-
opts.noextglob = opts.noext;
|
|
10660
|
-
}
|
|
10661
|
-
|
|
10662
|
-
const state = {
|
|
10663
|
-
input,
|
|
10664
|
-
index: -1,
|
|
10665
|
-
start: 0,
|
|
10666
|
-
dot: opts.dot === true,
|
|
10667
|
-
consumed: '',
|
|
10668
|
-
output: '',
|
|
10669
|
-
prefix: '',
|
|
10670
|
-
backtrack: false,
|
|
10671
|
-
negated: false,
|
|
10672
|
-
brackets: 0,
|
|
10673
|
-
braces: 0,
|
|
10674
|
-
parens: 0,
|
|
10675
|
-
quotes: 0,
|
|
10676
|
-
globstar: false,
|
|
10677
|
-
tokens
|
|
10678
|
-
};
|
|
10679
|
-
|
|
10680
|
-
input = utils$1.removePrefix(input, state);
|
|
10681
|
-
len = input.length;
|
|
10682
|
-
|
|
10683
|
-
const extglobs = [];
|
|
10684
|
-
const braces = [];
|
|
10685
|
-
const stack = [];
|
|
10686
|
-
let prev = bos;
|
|
10687
|
-
let value;
|
|
10688
|
-
|
|
10689
|
-
/**
|
|
10690
|
-
* Tokenizing helpers
|
|
10691
|
-
*/
|
|
10692
|
-
|
|
10693
|
-
const eos = () => state.index === len - 1;
|
|
10694
|
-
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
10695
|
-
const advance = state.advance = () => input[++state.index] || '';
|
|
10696
|
-
const remaining = () => input.slice(state.index + 1);
|
|
10697
|
-
const consume = (value = '', num = 0) => {
|
|
10698
|
-
state.consumed += value;
|
|
10699
|
-
state.index += num;
|
|
10700
|
-
};
|
|
10701
|
-
|
|
10702
|
-
const append = token => {
|
|
10703
|
-
state.output += token.output != null ? token.output : token.value;
|
|
10704
|
-
consume(token.value);
|
|
10705
|
-
};
|
|
10706
|
-
|
|
10707
|
-
const negate = () => {
|
|
10708
|
-
let count = 1;
|
|
10709
|
-
|
|
10710
|
-
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
10711
|
-
advance();
|
|
10712
|
-
state.start++;
|
|
10713
|
-
count++;
|
|
10714
|
-
}
|
|
10715
|
-
|
|
10716
|
-
if (count % 2 === 0) {
|
|
10717
|
-
return false;
|
|
10718
|
-
}
|
|
10719
|
-
|
|
10720
|
-
state.negated = true;
|
|
10721
|
-
state.start++;
|
|
10722
|
-
return true;
|
|
10723
|
-
};
|
|
10724
|
-
|
|
10725
|
-
const increment = type => {
|
|
10726
|
-
state[type]++;
|
|
10727
|
-
stack.push(type);
|
|
10728
|
-
};
|
|
10729
|
-
|
|
10730
|
-
const decrement = type => {
|
|
10731
|
-
state[type]--;
|
|
10732
|
-
stack.pop();
|
|
10733
|
-
};
|
|
10734
|
-
|
|
10735
|
-
/**
|
|
10736
|
-
* Push tokens onto the tokens array. This helper speeds up
|
|
10737
|
-
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
10738
|
-
* and 2) helping us avoid creating extra tokens when consecutive
|
|
10739
|
-
* characters are plain text. This improves performance and simplifies
|
|
10740
|
-
* lookbehinds.
|
|
10741
|
-
*/
|
|
10742
|
-
|
|
10743
|
-
const push = tok => {
|
|
10744
|
-
if (prev.type === 'globstar') {
|
|
10745
|
-
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
10746
|
-
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
10747
|
-
|
|
10748
|
-
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
10749
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
10750
|
-
prev.type = 'star';
|
|
10751
|
-
prev.value = '*';
|
|
10752
|
-
prev.output = star;
|
|
10753
|
-
state.output += prev.output;
|
|
10754
|
-
}
|
|
10755
|
-
}
|
|
10756
|
-
|
|
10757
|
-
if (extglobs.length && tok.type !== 'paren') {
|
|
10758
|
-
extglobs[extglobs.length - 1].inner += tok.value;
|
|
10759
|
-
}
|
|
10760
|
-
|
|
10761
|
-
if (tok.value || tok.output) append(tok);
|
|
10762
|
-
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
10763
|
-
prev.value += tok.value;
|
|
10764
|
-
prev.output = (prev.output || '') + tok.value;
|
|
10765
|
-
return;
|
|
10766
|
-
}
|
|
10767
|
-
|
|
10768
|
-
tok.prev = prev;
|
|
10769
|
-
tokens.push(tok);
|
|
10770
|
-
prev = tok;
|
|
10771
|
-
};
|
|
10772
|
-
|
|
10773
|
-
const extglobOpen = (type, value) => {
|
|
10774
|
-
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
10775
|
-
|
|
10776
|
-
token.prev = prev;
|
|
10777
|
-
token.parens = state.parens;
|
|
10778
|
-
token.output = state.output;
|
|
10779
|
-
const output = (opts.capture ? '(' : '') + token.open;
|
|
10780
|
-
|
|
10781
|
-
increment('parens');
|
|
10782
|
-
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
10783
|
-
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
10784
|
-
extglobs.push(token);
|
|
10785
|
-
};
|
|
10786
|
-
|
|
10787
|
-
const extglobClose = token => {
|
|
10788
|
-
let output = token.close + (opts.capture ? ')' : '');
|
|
10789
|
-
let rest;
|
|
10790
|
-
|
|
10791
|
-
if (token.type === 'negate') {
|
|
10792
|
-
let extglobStar = star;
|
|
10793
|
-
|
|
10794
|
-
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
10795
|
-
extglobStar = globstar(opts);
|
|
10796
|
-
}
|
|
10797
|
-
|
|
10798
|
-
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
10799
|
-
output = token.close = `)$))${extglobStar}`;
|
|
10800
|
-
}
|
|
10801
|
-
|
|
10802
|
-
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
10803
|
-
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
10804
|
-
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
10805
|
-
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
10806
|
-
//
|
|
10807
|
-
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
10808
|
-
const expression = parse$1(rest, { ...options, fastpaths: false }).output;
|
|
10809
|
-
|
|
10810
|
-
output = token.close = `)${expression})${extglobStar})`;
|
|
10811
|
-
}
|
|
10812
|
-
|
|
10813
|
-
if (token.prev.type === 'bos') {
|
|
10814
|
-
state.negatedExtglob = true;
|
|
10815
|
-
}
|
|
10816
|
-
}
|
|
10817
|
-
|
|
10818
|
-
push({ type: 'paren', extglob: true, value, output });
|
|
10819
|
-
decrement('parens');
|
|
10820
|
-
};
|
|
10821
|
-
|
|
10822
|
-
/**
|
|
10823
|
-
* Fast paths
|
|
10824
|
-
*/
|
|
10825
|
-
|
|
10826
|
-
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
10827
|
-
let backslashes = false;
|
|
10828
|
-
|
|
10829
|
-
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
10830
|
-
if (first === '\\') {
|
|
10831
|
-
backslashes = true;
|
|
10832
|
-
return m;
|
|
10833
|
-
}
|
|
10834
|
-
|
|
10835
|
-
if (first === '?') {
|
|
10836
|
-
if (esc) {
|
|
10837
|
-
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
10838
|
-
}
|
|
10839
|
-
if (index === 0) {
|
|
10840
|
-
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
10841
|
-
}
|
|
10842
|
-
return QMARK.repeat(chars.length);
|
|
10843
|
-
}
|
|
10844
|
-
|
|
10845
|
-
if (first === '.') {
|
|
10846
|
-
return DOT_LITERAL.repeat(chars.length);
|
|
10847
|
-
}
|
|
10848
|
-
|
|
10849
|
-
if (first === '*') {
|
|
10850
|
-
if (esc) {
|
|
10851
|
-
return esc + first + (rest ? star : '');
|
|
10852
|
-
}
|
|
10853
|
-
return star;
|
|
10854
|
-
}
|
|
10855
|
-
return esc ? m : `\\${m}`;
|
|
10856
|
-
});
|
|
10857
|
-
|
|
10858
|
-
if (backslashes === true) {
|
|
10859
|
-
if (opts.unescape === true) {
|
|
10860
|
-
output = output.replace(/\\/g, '');
|
|
10861
|
-
} else {
|
|
10862
|
-
output = output.replace(/\\+/g, m => {
|
|
10863
|
-
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
10864
|
-
});
|
|
10865
|
-
}
|
|
10866
|
-
}
|
|
10867
|
-
|
|
10868
|
-
if (output === input && opts.contains === true) {
|
|
10869
|
-
state.output = input;
|
|
10870
|
-
return state;
|
|
10871
|
-
}
|
|
10872
|
-
|
|
10873
|
-
state.output = utils$1.wrapOutput(output, state, options);
|
|
10874
|
-
return state;
|
|
10875
|
-
}
|
|
10876
|
-
|
|
10877
|
-
/**
|
|
10878
|
-
* Tokenize input until we reach end-of-string
|
|
10879
|
-
*/
|
|
10880
|
-
|
|
10881
|
-
while (!eos()) {
|
|
10882
|
-
value = advance();
|
|
10883
|
-
|
|
10884
|
-
if (value === '\u0000') {
|
|
10885
|
-
continue;
|
|
10886
|
-
}
|
|
10887
|
-
|
|
10888
|
-
/**
|
|
10889
|
-
* Escaped characters
|
|
10890
|
-
*/
|
|
10891
|
-
|
|
10892
|
-
if (value === '\\') {
|
|
10893
|
-
const next = peek();
|
|
10894
|
-
|
|
10895
|
-
if (next === '/' && opts.bash !== true) {
|
|
10896
|
-
continue;
|
|
10897
|
-
}
|
|
10898
|
-
|
|
10899
|
-
if (next === '.' || next === ';') {
|
|
10900
|
-
continue;
|
|
10901
|
-
}
|
|
10902
|
-
|
|
10903
|
-
if (!next) {
|
|
10904
|
-
value += '\\';
|
|
10905
|
-
push({ type: 'text', value });
|
|
10906
|
-
continue;
|
|
10907
|
-
}
|
|
10908
|
-
|
|
10909
|
-
// collapse slashes to reduce potential for exploits
|
|
10910
|
-
const match = /^\\+/.exec(remaining());
|
|
10911
|
-
let slashes = 0;
|
|
10912
|
-
|
|
10913
|
-
if (match && match[0].length > 2) {
|
|
10914
|
-
slashes = match[0].length;
|
|
10915
|
-
state.index += slashes;
|
|
10916
|
-
if (slashes % 2 !== 0) {
|
|
10917
|
-
value += '\\';
|
|
10918
|
-
}
|
|
10919
|
-
}
|
|
10920
|
-
|
|
10921
|
-
if (opts.unescape === true) {
|
|
10922
|
-
value = advance();
|
|
10923
|
-
} else {
|
|
10924
|
-
value += advance();
|
|
10925
|
-
}
|
|
10926
|
-
|
|
10927
|
-
if (state.brackets === 0) {
|
|
10928
|
-
push({ type: 'text', value });
|
|
10929
|
-
continue;
|
|
10930
|
-
}
|
|
10931
|
-
}
|
|
10932
|
-
|
|
10933
|
-
/**
|
|
10934
|
-
* If we're inside a regex character class, continue
|
|
10935
|
-
* until we reach the closing bracket.
|
|
10936
|
-
*/
|
|
10937
|
-
|
|
10938
|
-
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
10939
|
-
if (opts.posix !== false && value === ':') {
|
|
10940
|
-
const inner = prev.value.slice(1);
|
|
10941
|
-
if (inner.includes('[')) {
|
|
10942
|
-
prev.posix = true;
|
|
10943
|
-
|
|
10944
|
-
if (inner.includes(':')) {
|
|
10945
|
-
const idx = prev.value.lastIndexOf('[');
|
|
10946
|
-
const pre = prev.value.slice(0, idx);
|
|
10947
|
-
const rest = prev.value.slice(idx + 2);
|
|
10948
|
-
const posix = POSIX_REGEX_SOURCE[rest];
|
|
10949
|
-
if (posix) {
|
|
10950
|
-
prev.value = pre + posix;
|
|
10951
|
-
state.backtrack = true;
|
|
10952
|
-
advance();
|
|
10953
|
-
|
|
10954
|
-
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
10955
|
-
bos.output = ONE_CHAR;
|
|
10956
|
-
}
|
|
10957
|
-
continue;
|
|
10958
|
-
}
|
|
10959
|
-
}
|
|
10960
|
-
}
|
|
10961
|
-
}
|
|
10962
|
-
|
|
10963
|
-
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
10964
|
-
value = `\\${value}`;
|
|
10965
|
-
}
|
|
10966
|
-
|
|
10967
|
-
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
10968
|
-
value = `\\${value}`;
|
|
10969
|
-
}
|
|
10970
|
-
|
|
10971
|
-
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
10972
|
-
value = '^';
|
|
10973
|
-
}
|
|
10974
|
-
|
|
10975
|
-
prev.value += value;
|
|
10976
|
-
append({ value });
|
|
10977
|
-
continue;
|
|
10978
|
-
}
|
|
10979
|
-
|
|
10980
|
-
/**
|
|
10981
|
-
* If we're inside a quoted string, continue
|
|
10982
|
-
* until we reach the closing double quote.
|
|
10983
|
-
*/
|
|
10984
|
-
|
|
10985
|
-
if (state.quotes === 1 && value !== '"') {
|
|
10986
|
-
value = utils$1.escapeRegex(value);
|
|
10987
|
-
prev.value += value;
|
|
10988
|
-
append({ value });
|
|
10989
|
-
continue;
|
|
10990
|
-
}
|
|
10991
|
-
|
|
10992
|
-
/**
|
|
10993
|
-
* Double quotes
|
|
10994
|
-
*/
|
|
10995
|
-
|
|
10996
|
-
if (value === '"') {
|
|
10997
|
-
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
10998
|
-
if (opts.keepQuotes === true) {
|
|
10999
|
-
push({ type: 'text', value });
|
|
11000
|
-
}
|
|
11001
|
-
continue;
|
|
11002
|
-
}
|
|
11003
|
-
|
|
11004
|
-
/**
|
|
11005
|
-
* Parentheses
|
|
11006
|
-
*/
|
|
11007
|
-
|
|
11008
|
-
if (value === '(') {
|
|
11009
|
-
increment('parens');
|
|
11010
|
-
push({ type: 'paren', value });
|
|
11011
|
-
continue;
|
|
11012
|
-
}
|
|
11013
|
-
|
|
11014
|
-
if (value === ')') {
|
|
11015
|
-
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
11016
|
-
throw new SyntaxError(syntaxError('opening', '('));
|
|
11017
|
-
}
|
|
11018
|
-
|
|
11019
|
-
const extglob = extglobs[extglobs.length - 1];
|
|
11020
|
-
if (extglob && state.parens === extglob.parens + 1) {
|
|
11021
|
-
extglobClose(extglobs.pop());
|
|
11022
|
-
continue;
|
|
11023
|
-
}
|
|
11024
|
-
|
|
11025
|
-
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
11026
|
-
decrement('parens');
|
|
11027
|
-
continue;
|
|
11028
|
-
}
|
|
11029
|
-
|
|
11030
|
-
/**
|
|
11031
|
-
* Square brackets
|
|
11032
|
-
*/
|
|
11033
|
-
|
|
11034
|
-
if (value === '[') {
|
|
11035
|
-
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
11036
|
-
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
11037
|
-
throw new SyntaxError(syntaxError('closing', ']'));
|
|
11038
|
-
}
|
|
11039
|
-
|
|
11040
|
-
value = `\\${value}`;
|
|
11041
|
-
} else {
|
|
11042
|
-
increment('brackets');
|
|
11043
|
-
}
|
|
11044
|
-
|
|
11045
|
-
push({ type: 'bracket', value });
|
|
11046
|
-
continue;
|
|
11047
|
-
}
|
|
11048
|
-
|
|
11049
|
-
if (value === ']') {
|
|
11050
|
-
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
11051
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
11052
|
-
continue;
|
|
11053
|
-
}
|
|
11054
|
-
|
|
11055
|
-
if (state.brackets === 0) {
|
|
11056
|
-
if (opts.strictBrackets === true) {
|
|
11057
|
-
throw new SyntaxError(syntaxError('opening', '['));
|
|
11058
|
-
}
|
|
11059
|
-
|
|
11060
|
-
push({ type: 'text', value, output: `\\${value}` });
|
|
11061
|
-
continue;
|
|
11062
|
-
}
|
|
11063
|
-
|
|
11064
|
-
decrement('brackets');
|
|
11065
|
-
|
|
11066
|
-
const prevValue = prev.value.slice(1);
|
|
11067
|
-
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
11068
|
-
value = `/${value}`;
|
|
11069
|
-
}
|
|
11070
|
-
|
|
11071
|
-
prev.value += value;
|
|
11072
|
-
append({ value });
|
|
11073
|
-
|
|
11074
|
-
// when literal brackets are explicitly disabled
|
|
11075
|
-
// assume we should match with a regex character class
|
|
11076
|
-
if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
|
|
11077
|
-
continue;
|
|
11078
|
-
}
|
|
11079
|
-
|
|
11080
|
-
const escaped = utils$1.escapeRegex(prev.value);
|
|
11081
|
-
state.output = state.output.slice(0, -prev.value.length);
|
|
11082
|
-
|
|
11083
|
-
// when literal brackets are explicitly enabled
|
|
11084
|
-
// assume we should escape the brackets to match literal characters
|
|
11085
|
-
if (opts.literalBrackets === true) {
|
|
11086
|
-
state.output += escaped;
|
|
11087
|
-
prev.value = escaped;
|
|
11088
|
-
continue;
|
|
11089
|
-
}
|
|
11090
|
-
|
|
11091
|
-
// when the user specifies nothing, try to match both
|
|
11092
|
-
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
11093
|
-
state.output += prev.value;
|
|
11094
|
-
continue;
|
|
11095
|
-
}
|
|
11096
|
-
|
|
11097
|
-
/**
|
|
11098
|
-
* Braces
|
|
11099
|
-
*/
|
|
11100
|
-
|
|
11101
|
-
if (value === '{' && opts.nobrace !== true) {
|
|
11102
|
-
increment('braces');
|
|
11103
|
-
|
|
11104
|
-
const open = {
|
|
11105
|
-
type: 'brace',
|
|
11106
|
-
value,
|
|
11107
|
-
output: '(',
|
|
11108
|
-
outputIndex: state.output.length,
|
|
11109
|
-
tokensIndex: state.tokens.length
|
|
11110
|
-
};
|
|
11111
|
-
|
|
11112
|
-
braces.push(open);
|
|
11113
|
-
push(open);
|
|
11114
|
-
continue;
|
|
11115
|
-
}
|
|
11116
|
-
|
|
11117
|
-
if (value === '}') {
|
|
11118
|
-
const brace = braces[braces.length - 1];
|
|
11119
|
-
|
|
11120
|
-
if (opts.nobrace === true || !brace) {
|
|
11121
|
-
push({ type: 'text', value, output: value });
|
|
11122
|
-
continue;
|
|
11123
|
-
}
|
|
11124
|
-
|
|
11125
|
-
let output = ')';
|
|
11126
|
-
|
|
11127
|
-
if (brace.dots === true) {
|
|
11128
|
-
const arr = tokens.slice();
|
|
11129
|
-
const range = [];
|
|
11130
|
-
|
|
11131
|
-
for (let i = arr.length - 1; i >= 0; i--) {
|
|
11132
|
-
tokens.pop();
|
|
11133
|
-
if (arr[i].type === 'brace') {
|
|
11134
|
-
break;
|
|
11135
|
-
}
|
|
11136
|
-
if (arr[i].type !== 'dots') {
|
|
11137
|
-
range.unshift(arr[i].value);
|
|
11138
|
-
}
|
|
11139
|
-
}
|
|
11140
|
-
|
|
11141
|
-
output = expandRange(range, opts);
|
|
11142
|
-
state.backtrack = true;
|
|
11143
|
-
}
|
|
11144
|
-
|
|
11145
|
-
if (brace.comma !== true && brace.dots !== true) {
|
|
11146
|
-
const out = state.output.slice(0, brace.outputIndex);
|
|
11147
|
-
const toks = state.tokens.slice(brace.tokensIndex);
|
|
11148
|
-
brace.value = brace.output = '\\{';
|
|
11149
|
-
value = output = '\\}';
|
|
11150
|
-
state.output = out;
|
|
11151
|
-
for (const t of toks) {
|
|
11152
|
-
state.output += (t.output || t.value);
|
|
11153
|
-
}
|
|
11154
|
-
}
|
|
11155
|
-
|
|
11156
|
-
push({ type: 'brace', value, output });
|
|
11157
|
-
decrement('braces');
|
|
11158
|
-
braces.pop();
|
|
11159
|
-
continue;
|
|
11160
|
-
}
|
|
11161
|
-
|
|
11162
|
-
/**
|
|
11163
|
-
* Pipes
|
|
11164
|
-
*/
|
|
11165
|
-
|
|
11166
|
-
if (value === '|') {
|
|
11167
|
-
if (extglobs.length > 0) {
|
|
11168
|
-
extglobs[extglobs.length - 1].conditions++;
|
|
11169
|
-
}
|
|
11170
|
-
push({ type: 'text', value });
|
|
11171
|
-
continue;
|
|
11172
|
-
}
|
|
11173
|
-
|
|
11174
|
-
/**
|
|
11175
|
-
* Commas
|
|
11176
|
-
*/
|
|
11177
|
-
|
|
11178
|
-
if (value === ',') {
|
|
11179
|
-
let output = value;
|
|
11180
|
-
|
|
11181
|
-
const brace = braces[braces.length - 1];
|
|
11182
|
-
if (brace && stack[stack.length - 1] === 'braces') {
|
|
11183
|
-
brace.comma = true;
|
|
11184
|
-
output = '|';
|
|
11185
|
-
}
|
|
11186
|
-
|
|
11187
|
-
push({ type: 'comma', value, output });
|
|
11188
|
-
continue;
|
|
11189
|
-
}
|
|
11190
|
-
|
|
11191
|
-
/**
|
|
11192
|
-
* Slashes
|
|
11193
|
-
*/
|
|
11194
|
-
|
|
11195
|
-
if (value === '/') {
|
|
11196
|
-
// if the beginning of the glob is "./", advance the start
|
|
11197
|
-
// to the current index, and don't add the "./" characters
|
|
11198
|
-
// to the state. This greatly simplifies lookbehinds when
|
|
11199
|
-
// checking for BOS characters like "!" and "." (not "./")
|
|
11200
|
-
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
11201
|
-
state.start = state.index + 1;
|
|
11202
|
-
state.consumed = '';
|
|
11203
|
-
state.output = '';
|
|
11204
|
-
tokens.pop();
|
|
11205
|
-
prev = bos; // reset "prev" to the first token
|
|
11206
|
-
continue;
|
|
11207
|
-
}
|
|
11208
|
-
|
|
11209
|
-
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
11210
|
-
continue;
|
|
11211
|
-
}
|
|
11212
|
-
|
|
11213
|
-
/**
|
|
11214
|
-
* Dots
|
|
11215
|
-
*/
|
|
11216
|
-
|
|
11217
|
-
if (value === '.') {
|
|
11218
|
-
if (state.braces > 0 && prev.type === 'dot') {
|
|
11219
|
-
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
11220
|
-
const brace = braces[braces.length - 1];
|
|
11221
|
-
prev.type = 'dots';
|
|
11222
|
-
prev.output += value;
|
|
11223
|
-
prev.value += value;
|
|
11224
|
-
brace.dots = true;
|
|
11225
|
-
continue;
|
|
11226
|
-
}
|
|
11227
|
-
|
|
11228
|
-
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
11229
|
-
push({ type: 'text', value, output: DOT_LITERAL });
|
|
11230
|
-
continue;
|
|
11231
|
-
}
|
|
11232
|
-
|
|
11233
|
-
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
11234
|
-
continue;
|
|
11235
|
-
}
|
|
10147
|
+
exports.supportsLookbehinds = () => {
|
|
10148
|
+
const segs = process.version.slice(1).split('.').map(Number);
|
|
10149
|
+
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
|
|
10150
|
+
return true;
|
|
10151
|
+
}
|
|
10152
|
+
return false;
|
|
10153
|
+
};
|
|
11236
10154
|
|
|
11237
|
-
|
|
11238
|
-
|
|
11239
|
-
|
|
10155
|
+
exports.isWindows = options => {
|
|
10156
|
+
if (options && typeof options.windows === 'boolean') {
|
|
10157
|
+
return options.windows;
|
|
10158
|
+
}
|
|
10159
|
+
return win32 === true || path.sep === '\\';
|
|
10160
|
+
};
|
|
11240
10161
|
|
|
11241
|
-
|
|
11242
|
-
|
|
11243
|
-
|
|
11244
|
-
|
|
11245
|
-
|
|
11246
|
-
|
|
10162
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
10163
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
10164
|
+
if (idx === -1) return input;
|
|
10165
|
+
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
10166
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
10167
|
+
};
|
|
11247
10168
|
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
10169
|
+
exports.removePrefix = (input, state = {}) => {
|
|
10170
|
+
let output = input;
|
|
10171
|
+
if (output.startsWith('./')) {
|
|
10172
|
+
output = output.slice(2);
|
|
10173
|
+
state.prefix = './';
|
|
10174
|
+
}
|
|
10175
|
+
return output;
|
|
10176
|
+
};
|
|
11251
10177
|
|
|
11252
|
-
|
|
11253
|
-
|
|
11254
|
-
|
|
10178
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
10179
|
+
const prepend = options.contains ? '' : '^';
|
|
10180
|
+
const append = options.contains ? '' : '$';
|
|
11255
10181
|
|
|
11256
|
-
|
|
11257
|
-
|
|
11258
|
-
|
|
10182
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
10183
|
+
if (state.negated === true) {
|
|
10184
|
+
output = `(?:^(?!${output}).*$)`;
|
|
10185
|
+
}
|
|
10186
|
+
return output;
|
|
10187
|
+
};
|
|
10188
|
+
} (utils));
|
|
10189
|
+
return utils;
|
|
10190
|
+
}
|
|
11259
10191
|
|
|
11260
|
-
|
|
11261
|
-
|
|
11262
|
-
}
|
|
10192
|
+
var scan_1;
|
|
10193
|
+
var hasRequiredScan;
|
|
11263
10194
|
|
|
11264
|
-
|
|
11265
|
-
|
|
11266
|
-
|
|
11267
|
-
}
|
|
10195
|
+
function requireScan () {
|
|
10196
|
+
if (hasRequiredScan) return scan_1;
|
|
10197
|
+
hasRequiredScan = 1;
|
|
11268
10198
|
|
|
11269
|
-
|
|
11270
|
-
|
|
11271
|
-
|
|
10199
|
+
const utils = /*@__PURE__*/ requireUtils();
|
|
10200
|
+
const {
|
|
10201
|
+
CHAR_ASTERISK, /* * */
|
|
10202
|
+
CHAR_AT, /* @ */
|
|
10203
|
+
CHAR_BACKWARD_SLASH, /* \ */
|
|
10204
|
+
CHAR_COMMA, /* , */
|
|
10205
|
+
CHAR_DOT, /* . */
|
|
10206
|
+
CHAR_EXCLAMATION_MARK, /* ! */
|
|
10207
|
+
CHAR_FORWARD_SLASH, /* / */
|
|
10208
|
+
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
10209
|
+
CHAR_LEFT_PARENTHESES, /* ( */
|
|
10210
|
+
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
10211
|
+
CHAR_PLUS, /* + */
|
|
10212
|
+
CHAR_QUESTION_MARK, /* ? */
|
|
10213
|
+
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
10214
|
+
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
10215
|
+
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
10216
|
+
} = /*@__PURE__*/ requireConstants();
|
|
10217
|
+
|
|
10218
|
+
const isPathSeparator = code => {
|
|
10219
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
10220
|
+
};
|
|
11272
10221
|
|
|
11273
|
-
|
|
11274
|
-
|
|
11275
|
-
|
|
10222
|
+
const depth = token => {
|
|
10223
|
+
if (token.isPrefix !== true) {
|
|
10224
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
10225
|
+
}
|
|
10226
|
+
};
|
|
11276
10227
|
|
|
11277
|
-
|
|
11278
|
-
|
|
11279
|
-
|
|
11280
|
-
|
|
11281
|
-
|
|
11282
|
-
|
|
11283
|
-
|
|
10228
|
+
/**
|
|
10229
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
10230
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
10231
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
10232
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
10233
|
+
*
|
|
10234
|
+
* ```js
|
|
10235
|
+
* const pm = require('picomatch');
|
|
10236
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
10237
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
10238
|
+
* ```
|
|
10239
|
+
* @param {String} `str`
|
|
10240
|
+
* @param {Object} `options`
|
|
10241
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
10242
|
+
* @api public
|
|
10243
|
+
*/
|
|
10244
|
+
|
|
10245
|
+
const scan = (input, options) => {
|
|
10246
|
+
const opts = options || {};
|
|
10247
|
+
|
|
10248
|
+
const length = input.length - 1;
|
|
10249
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
10250
|
+
const slashes = [];
|
|
10251
|
+
const tokens = [];
|
|
10252
|
+
const parts = [];
|
|
10253
|
+
|
|
10254
|
+
let str = input;
|
|
10255
|
+
let index = -1;
|
|
10256
|
+
let start = 0;
|
|
10257
|
+
let lastIndex = 0;
|
|
10258
|
+
let isBrace = false;
|
|
10259
|
+
let isBracket = false;
|
|
10260
|
+
let isGlob = false;
|
|
10261
|
+
let isExtglob = false;
|
|
10262
|
+
let isGlobstar = false;
|
|
10263
|
+
let braceEscaped = false;
|
|
10264
|
+
let backslashes = false;
|
|
10265
|
+
let negated = false;
|
|
10266
|
+
let negatedExtglob = false;
|
|
10267
|
+
let finished = false;
|
|
10268
|
+
let braces = 0;
|
|
10269
|
+
let prev;
|
|
10270
|
+
let code;
|
|
10271
|
+
let token = { value: '', depth: 0, isGlob: false };
|
|
10272
|
+
|
|
10273
|
+
const eos = () => index >= length;
|
|
10274
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
10275
|
+
const advance = () => {
|
|
10276
|
+
prev = code;
|
|
10277
|
+
return str.charCodeAt(++index);
|
|
10278
|
+
};
|
|
10279
|
+
|
|
10280
|
+
while (index < length) {
|
|
10281
|
+
code = advance();
|
|
10282
|
+
let next;
|
|
10283
|
+
|
|
10284
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
10285
|
+
backslashes = token.backslashes = true;
|
|
10286
|
+
code = advance();
|
|
10287
|
+
|
|
10288
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
10289
|
+
braceEscaped = true;
|
|
10290
|
+
}
|
|
10291
|
+
continue;
|
|
10292
|
+
}
|
|
10293
|
+
|
|
10294
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
10295
|
+
braces++;
|
|
10296
|
+
|
|
10297
|
+
while (eos() !== true && (code = advance())) {
|
|
10298
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
10299
|
+
backslashes = token.backslashes = true;
|
|
10300
|
+
advance();
|
|
10301
|
+
continue;
|
|
10302
|
+
}
|
|
10303
|
+
|
|
10304
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
10305
|
+
braces++;
|
|
10306
|
+
continue;
|
|
10307
|
+
}
|
|
10308
|
+
|
|
10309
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
10310
|
+
isBrace = token.isBrace = true;
|
|
10311
|
+
isGlob = token.isGlob = true;
|
|
10312
|
+
finished = true;
|
|
10313
|
+
|
|
10314
|
+
if (scanToEnd === true) {
|
|
10315
|
+
continue;
|
|
10316
|
+
}
|
|
10317
|
+
|
|
10318
|
+
break;
|
|
10319
|
+
}
|
|
10320
|
+
|
|
10321
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
10322
|
+
isBrace = token.isBrace = true;
|
|
10323
|
+
isGlob = token.isGlob = true;
|
|
10324
|
+
finished = true;
|
|
10325
|
+
|
|
10326
|
+
if (scanToEnd === true) {
|
|
10327
|
+
continue;
|
|
10328
|
+
}
|
|
10329
|
+
|
|
10330
|
+
break;
|
|
10331
|
+
}
|
|
10332
|
+
|
|
10333
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
10334
|
+
braces--;
|
|
10335
|
+
|
|
10336
|
+
if (braces === 0) {
|
|
10337
|
+
braceEscaped = false;
|
|
10338
|
+
isBrace = token.isBrace = true;
|
|
10339
|
+
finished = true;
|
|
10340
|
+
break;
|
|
10341
|
+
}
|
|
10342
|
+
}
|
|
10343
|
+
}
|
|
10344
|
+
|
|
10345
|
+
if (scanToEnd === true) {
|
|
10346
|
+
continue;
|
|
10347
|
+
}
|
|
10348
|
+
|
|
10349
|
+
break;
|
|
10350
|
+
}
|
|
10351
|
+
|
|
10352
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
10353
|
+
slashes.push(index);
|
|
10354
|
+
tokens.push(token);
|
|
10355
|
+
token = { value: '', depth: 0, isGlob: false };
|
|
10356
|
+
|
|
10357
|
+
if (finished === true) continue;
|
|
10358
|
+
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
10359
|
+
start += 2;
|
|
10360
|
+
continue;
|
|
10361
|
+
}
|
|
10362
|
+
|
|
10363
|
+
lastIndex = index + 1;
|
|
10364
|
+
continue;
|
|
10365
|
+
}
|
|
10366
|
+
|
|
10367
|
+
if (opts.noext !== true) {
|
|
10368
|
+
const isExtglobChar = code === CHAR_PLUS
|
|
10369
|
+
|| code === CHAR_AT
|
|
10370
|
+
|| code === CHAR_ASTERISK
|
|
10371
|
+
|| code === CHAR_QUESTION_MARK
|
|
10372
|
+
|| code === CHAR_EXCLAMATION_MARK;
|
|
10373
|
+
|
|
10374
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
10375
|
+
isGlob = token.isGlob = true;
|
|
10376
|
+
isExtglob = token.isExtglob = true;
|
|
10377
|
+
finished = true;
|
|
10378
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
10379
|
+
negatedExtglob = true;
|
|
10380
|
+
}
|
|
10381
|
+
|
|
10382
|
+
if (scanToEnd === true) {
|
|
10383
|
+
while (eos() !== true && (code = advance())) {
|
|
10384
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
10385
|
+
backslashes = token.backslashes = true;
|
|
10386
|
+
code = advance();
|
|
10387
|
+
continue;
|
|
10388
|
+
}
|
|
10389
|
+
|
|
10390
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
10391
|
+
isGlob = token.isGlob = true;
|
|
10392
|
+
finished = true;
|
|
10393
|
+
break;
|
|
10394
|
+
}
|
|
10395
|
+
}
|
|
10396
|
+
continue;
|
|
10397
|
+
}
|
|
10398
|
+
break;
|
|
10399
|
+
}
|
|
10400
|
+
}
|
|
10401
|
+
|
|
10402
|
+
if (code === CHAR_ASTERISK) {
|
|
10403
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
10404
|
+
isGlob = token.isGlob = true;
|
|
10405
|
+
finished = true;
|
|
10406
|
+
|
|
10407
|
+
if (scanToEnd === true) {
|
|
10408
|
+
continue;
|
|
10409
|
+
}
|
|
10410
|
+
break;
|
|
10411
|
+
}
|
|
10412
|
+
|
|
10413
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
10414
|
+
isGlob = token.isGlob = true;
|
|
10415
|
+
finished = true;
|
|
10416
|
+
|
|
10417
|
+
if (scanToEnd === true) {
|
|
10418
|
+
continue;
|
|
10419
|
+
}
|
|
10420
|
+
break;
|
|
10421
|
+
}
|
|
10422
|
+
|
|
10423
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
10424
|
+
while (eos() !== true && (next = advance())) {
|
|
10425
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
10426
|
+
backslashes = token.backslashes = true;
|
|
10427
|
+
advance();
|
|
10428
|
+
continue;
|
|
10429
|
+
}
|
|
10430
|
+
|
|
10431
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
10432
|
+
isBracket = token.isBracket = true;
|
|
10433
|
+
isGlob = token.isGlob = true;
|
|
10434
|
+
finished = true;
|
|
10435
|
+
break;
|
|
10436
|
+
}
|
|
10437
|
+
}
|
|
10438
|
+
|
|
10439
|
+
if (scanToEnd === true) {
|
|
10440
|
+
continue;
|
|
10441
|
+
}
|
|
10442
|
+
|
|
10443
|
+
break;
|
|
10444
|
+
}
|
|
10445
|
+
|
|
10446
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
10447
|
+
negated = token.negated = true;
|
|
10448
|
+
start++;
|
|
10449
|
+
continue;
|
|
10450
|
+
}
|
|
10451
|
+
|
|
10452
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
10453
|
+
isGlob = token.isGlob = true;
|
|
10454
|
+
|
|
10455
|
+
if (scanToEnd === true) {
|
|
10456
|
+
while (eos() !== true && (code = advance())) {
|
|
10457
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
10458
|
+
backslashes = token.backslashes = true;
|
|
10459
|
+
code = advance();
|
|
10460
|
+
continue;
|
|
10461
|
+
}
|
|
10462
|
+
|
|
10463
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
10464
|
+
finished = true;
|
|
10465
|
+
break;
|
|
10466
|
+
}
|
|
10467
|
+
}
|
|
10468
|
+
continue;
|
|
10469
|
+
}
|
|
10470
|
+
break;
|
|
10471
|
+
}
|
|
10472
|
+
|
|
10473
|
+
if (isGlob === true) {
|
|
10474
|
+
finished = true;
|
|
10475
|
+
|
|
10476
|
+
if (scanToEnd === true) {
|
|
10477
|
+
continue;
|
|
10478
|
+
}
|
|
10479
|
+
|
|
10480
|
+
break;
|
|
10481
|
+
}
|
|
10482
|
+
}
|
|
11284
10483
|
|
|
11285
|
-
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
}
|
|
10484
|
+
if (opts.noext === true) {
|
|
10485
|
+
isExtglob = false;
|
|
10486
|
+
isGlob = false;
|
|
10487
|
+
}
|
|
11290
10488
|
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
|
|
10489
|
+
let base = str;
|
|
10490
|
+
let prefix = '';
|
|
10491
|
+
let glob = '';
|
|
11294
10492
|
|
|
11295
|
-
|
|
11296
|
-
|
|
11297
|
-
|
|
11298
|
-
|
|
11299
|
-
|
|
10493
|
+
if (start > 0) {
|
|
10494
|
+
prefix = str.slice(0, start);
|
|
10495
|
+
str = str.slice(start);
|
|
10496
|
+
lastIndex -= start;
|
|
10497
|
+
}
|
|
11300
10498
|
|
|
11301
|
-
|
|
11302
|
-
|
|
11303
|
-
|
|
11304
|
-
|
|
10499
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
10500
|
+
base = str.slice(0, lastIndex);
|
|
10501
|
+
glob = str.slice(lastIndex);
|
|
10502
|
+
} else if (isGlob === true) {
|
|
10503
|
+
base = '';
|
|
10504
|
+
glob = str;
|
|
10505
|
+
} else {
|
|
10506
|
+
base = str;
|
|
10507
|
+
}
|
|
11305
10508
|
|
|
11306
|
-
|
|
11307
|
-
|
|
11308
|
-
|
|
11309
|
-
|
|
10509
|
+
if (base && base !== '' && base !== '/' && base !== str) {
|
|
10510
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
10511
|
+
base = base.slice(0, -1);
|
|
10512
|
+
}
|
|
10513
|
+
}
|
|
11310
10514
|
|
|
11311
|
-
|
|
11312
|
-
|
|
11313
|
-
}
|
|
10515
|
+
if (opts.unescape === true) {
|
|
10516
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
11314
10517
|
|
|
11315
|
-
|
|
11316
|
-
|
|
11317
|
-
|
|
10518
|
+
if (base && backslashes === true) {
|
|
10519
|
+
base = utils.removeBackslashes(base);
|
|
10520
|
+
}
|
|
10521
|
+
}
|
|
11318
10522
|
|
|
11319
|
-
|
|
11320
|
-
|
|
11321
|
-
|
|
11322
|
-
|
|
11323
|
-
|
|
10523
|
+
const state = {
|
|
10524
|
+
prefix,
|
|
10525
|
+
input,
|
|
10526
|
+
start,
|
|
10527
|
+
base,
|
|
10528
|
+
glob,
|
|
10529
|
+
isBrace,
|
|
10530
|
+
isBracket,
|
|
10531
|
+
isGlob,
|
|
10532
|
+
isExtglob,
|
|
10533
|
+
isGlobstar,
|
|
10534
|
+
negated,
|
|
10535
|
+
negatedExtglob
|
|
10536
|
+
};
|
|
10537
|
+
|
|
10538
|
+
if (opts.tokens === true) {
|
|
10539
|
+
state.maxDepth = 0;
|
|
10540
|
+
if (!isPathSeparator(code)) {
|
|
10541
|
+
tokens.push(token);
|
|
10542
|
+
}
|
|
10543
|
+
state.tokens = tokens;
|
|
10544
|
+
}
|
|
11324
10545
|
|
|
11325
|
-
|
|
11326
|
-
|
|
11327
|
-
|
|
10546
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
10547
|
+
let prevIndex;
|
|
10548
|
+
|
|
10549
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
10550
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
10551
|
+
const i = slashes[idx];
|
|
10552
|
+
const value = input.slice(n, i);
|
|
10553
|
+
if (opts.tokens) {
|
|
10554
|
+
if (idx === 0 && start !== 0) {
|
|
10555
|
+
tokens[idx].isPrefix = true;
|
|
10556
|
+
tokens[idx].value = prefix;
|
|
10557
|
+
} else {
|
|
10558
|
+
tokens[idx].value = value;
|
|
10559
|
+
}
|
|
10560
|
+
depth(tokens[idx]);
|
|
10561
|
+
state.maxDepth += tokens[idx].depth;
|
|
10562
|
+
}
|
|
10563
|
+
if (idx !== 0 || value !== '') {
|
|
10564
|
+
parts.push(value);
|
|
10565
|
+
}
|
|
10566
|
+
prevIndex = i;
|
|
10567
|
+
}
|
|
10568
|
+
|
|
10569
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
10570
|
+
const value = input.slice(prevIndex + 1);
|
|
10571
|
+
parts.push(value);
|
|
10572
|
+
|
|
10573
|
+
if (opts.tokens) {
|
|
10574
|
+
tokens[tokens.length - 1].value = value;
|
|
10575
|
+
depth(tokens[tokens.length - 1]);
|
|
10576
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
10577
|
+
}
|
|
10578
|
+
}
|
|
10579
|
+
|
|
10580
|
+
state.slashes = slashes;
|
|
10581
|
+
state.parts = parts;
|
|
10582
|
+
}
|
|
11328
10583
|
|
|
11329
|
-
|
|
11330
|
-
|
|
11331
|
-
*/
|
|
10584
|
+
return state;
|
|
10585
|
+
};
|
|
11332
10586
|
|
|
11333
|
-
|
|
11334
|
-
|
|
11335
|
-
|
|
11336
|
-
}
|
|
10587
|
+
scan_1 = scan;
|
|
10588
|
+
return scan_1;
|
|
10589
|
+
}
|
|
11337
10590
|
|
|
11338
|
-
|
|
11339
|
-
|
|
11340
|
-
value += match[0];
|
|
11341
|
-
state.index += match[0].length;
|
|
11342
|
-
}
|
|
10591
|
+
var parse_1;
|
|
10592
|
+
var hasRequiredParse;
|
|
11343
10593
|
|
|
11344
|
-
|
|
11345
|
-
|
|
11346
|
-
|
|
10594
|
+
function requireParse () {
|
|
10595
|
+
if (hasRequiredParse) return parse_1;
|
|
10596
|
+
hasRequiredParse = 1;
|
|
11347
10597
|
|
|
11348
|
-
|
|
11349
|
-
|
|
11350
|
-
*/
|
|
10598
|
+
const constants = /*@__PURE__*/ requireConstants();
|
|
10599
|
+
const utils = /*@__PURE__*/ requireUtils();
|
|
11351
10600
|
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
prev.value += value;
|
|
11356
|
-
prev.output = star;
|
|
11357
|
-
state.backtrack = true;
|
|
11358
|
-
state.globstar = true;
|
|
11359
|
-
consume(value);
|
|
11360
|
-
continue;
|
|
11361
|
-
}
|
|
11362
|
-
|
|
11363
|
-
let rest = remaining();
|
|
11364
|
-
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
11365
|
-
extglobOpen('star', value);
|
|
11366
|
-
continue;
|
|
11367
|
-
}
|
|
11368
|
-
|
|
11369
|
-
if (prev.type === 'star') {
|
|
11370
|
-
if (opts.noglobstar === true) {
|
|
11371
|
-
consume(value);
|
|
11372
|
-
continue;
|
|
11373
|
-
}
|
|
11374
|
-
|
|
11375
|
-
const prior = prev.prev;
|
|
11376
|
-
const before = prior.prev;
|
|
11377
|
-
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
11378
|
-
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
11379
|
-
|
|
11380
|
-
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
11381
|
-
push({ type: 'star', value, output: '' });
|
|
11382
|
-
continue;
|
|
11383
|
-
}
|
|
11384
|
-
|
|
11385
|
-
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
11386
|
-
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
11387
|
-
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
11388
|
-
push({ type: 'star', value, output: '' });
|
|
11389
|
-
continue;
|
|
11390
|
-
}
|
|
11391
|
-
|
|
11392
|
-
// strip consecutive `/**/`
|
|
11393
|
-
while (rest.slice(0, 3) === '/**') {
|
|
11394
|
-
const after = input[state.index + 4];
|
|
11395
|
-
if (after && after !== '/') {
|
|
11396
|
-
break;
|
|
11397
|
-
}
|
|
11398
|
-
rest = rest.slice(3);
|
|
11399
|
-
consume('/**', 3);
|
|
11400
|
-
}
|
|
11401
|
-
|
|
11402
|
-
if (prior.type === 'bos' && eos()) {
|
|
11403
|
-
prev.type = 'globstar';
|
|
11404
|
-
prev.value += value;
|
|
11405
|
-
prev.output = globstar(opts);
|
|
11406
|
-
state.output = prev.output;
|
|
11407
|
-
state.globstar = true;
|
|
11408
|
-
consume(value);
|
|
11409
|
-
continue;
|
|
11410
|
-
}
|
|
11411
|
-
|
|
11412
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
11413
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
11414
|
-
prior.output = `(?:${prior.output}`;
|
|
11415
|
-
|
|
11416
|
-
prev.type = 'globstar';
|
|
11417
|
-
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
11418
|
-
prev.value += value;
|
|
11419
|
-
state.globstar = true;
|
|
11420
|
-
state.output += prior.output + prev.output;
|
|
11421
|
-
consume(value);
|
|
11422
|
-
continue;
|
|
11423
|
-
}
|
|
11424
|
-
|
|
11425
|
-
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
11426
|
-
const end = rest[1] !== void 0 ? '|$' : '';
|
|
11427
|
-
|
|
11428
|
-
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
11429
|
-
prior.output = `(?:${prior.output}`;
|
|
11430
|
-
|
|
11431
|
-
prev.type = 'globstar';
|
|
11432
|
-
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
11433
|
-
prev.value += value;
|
|
11434
|
-
|
|
11435
|
-
state.output += prior.output + prev.output;
|
|
11436
|
-
state.globstar = true;
|
|
11437
|
-
|
|
11438
|
-
consume(value + advance());
|
|
11439
|
-
|
|
11440
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
11441
|
-
continue;
|
|
11442
|
-
}
|
|
11443
|
-
|
|
11444
|
-
if (prior.type === 'bos' && rest[0] === '/') {
|
|
11445
|
-
prev.type = 'globstar';
|
|
11446
|
-
prev.value += value;
|
|
11447
|
-
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
11448
|
-
state.output = prev.output;
|
|
11449
|
-
state.globstar = true;
|
|
11450
|
-
consume(value + advance());
|
|
11451
|
-
push({ type: 'slash', value: '/', output: '' });
|
|
11452
|
-
continue;
|
|
11453
|
-
}
|
|
11454
|
-
|
|
11455
|
-
// remove single star from output
|
|
11456
|
-
state.output = state.output.slice(0, -prev.output.length);
|
|
11457
|
-
|
|
11458
|
-
// reset previous token to globstar
|
|
11459
|
-
prev.type = 'globstar';
|
|
11460
|
-
prev.output = globstar(opts);
|
|
11461
|
-
prev.value += value;
|
|
11462
|
-
|
|
11463
|
-
// reset output with globstar
|
|
11464
|
-
state.output += prev.output;
|
|
11465
|
-
state.globstar = true;
|
|
11466
|
-
consume(value);
|
|
11467
|
-
continue;
|
|
11468
|
-
}
|
|
11469
|
-
|
|
11470
|
-
const token = { type: 'star', value, output: star };
|
|
11471
|
-
|
|
11472
|
-
if (opts.bash === true) {
|
|
11473
|
-
token.output = '.*?';
|
|
11474
|
-
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
11475
|
-
token.output = nodot + token.output;
|
|
11476
|
-
}
|
|
11477
|
-
push(token);
|
|
11478
|
-
continue;
|
|
11479
|
-
}
|
|
11480
|
-
|
|
11481
|
-
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
11482
|
-
token.output = value;
|
|
11483
|
-
push(token);
|
|
11484
|
-
continue;
|
|
11485
|
-
}
|
|
11486
|
-
|
|
11487
|
-
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
11488
|
-
if (prev.type === 'dot') {
|
|
11489
|
-
state.output += NO_DOT_SLASH;
|
|
11490
|
-
prev.output += NO_DOT_SLASH;
|
|
11491
|
-
|
|
11492
|
-
} else if (opts.dot === true) {
|
|
11493
|
-
state.output += NO_DOTS_SLASH;
|
|
11494
|
-
prev.output += NO_DOTS_SLASH;
|
|
11495
|
-
|
|
11496
|
-
} else {
|
|
11497
|
-
state.output += nodot;
|
|
11498
|
-
prev.output += nodot;
|
|
11499
|
-
}
|
|
11500
|
-
|
|
11501
|
-
if (peek() !== '*') {
|
|
11502
|
-
state.output += ONE_CHAR;
|
|
11503
|
-
prev.output += ONE_CHAR;
|
|
11504
|
-
}
|
|
11505
|
-
}
|
|
11506
|
-
|
|
11507
|
-
push(token);
|
|
11508
|
-
}
|
|
10601
|
+
/**
|
|
10602
|
+
* Constants
|
|
10603
|
+
*/
|
|
11509
10604
|
|
|
11510
|
-
|
|
11511
|
-
|
|
11512
|
-
|
|
11513
|
-
|
|
11514
|
-
|
|
10605
|
+
const {
|
|
10606
|
+
MAX_LENGTH,
|
|
10607
|
+
POSIX_REGEX_SOURCE,
|
|
10608
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
10609
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
10610
|
+
REPLACEMENTS
|
|
10611
|
+
} = constants;
|
|
10612
|
+
|
|
10613
|
+
/**
|
|
10614
|
+
* Helpers
|
|
10615
|
+
*/
|
|
10616
|
+
|
|
10617
|
+
const expandRange = (args, options) => {
|
|
10618
|
+
if (typeof options.expandRange === 'function') {
|
|
10619
|
+
return options.expandRange(...args, options);
|
|
10620
|
+
}
|
|
11515
10621
|
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
state.output = utils$1.escapeLast(state.output, '(');
|
|
11519
|
-
decrement('parens');
|
|
11520
|
-
}
|
|
10622
|
+
args.sort();
|
|
10623
|
+
const value = `[${args.join('-')}]`;
|
|
11521
10624
|
|
|
11522
|
-
|
|
11523
|
-
|
|
11524
|
-
state.output = utils$1.escapeLast(state.output, '{');
|
|
11525
|
-
decrement('braces');
|
|
11526
|
-
}
|
|
10625
|
+
return value;
|
|
10626
|
+
};
|
|
11527
10627
|
|
|
11528
|
-
|
|
11529
|
-
|
|
11530
|
-
|
|
10628
|
+
/**
|
|
10629
|
+
* Create the message for a syntax error
|
|
10630
|
+
*/
|
|
11531
10631
|
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
10632
|
+
const syntaxError = (type, char) => {
|
|
10633
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
10634
|
+
};
|
|
11535
10635
|
|
|
11536
|
-
|
|
11537
|
-
|
|
10636
|
+
/**
|
|
10637
|
+
* Parse the given input string.
|
|
10638
|
+
* @param {String} input
|
|
10639
|
+
* @param {Object} options
|
|
10640
|
+
* @return {Object}
|
|
10641
|
+
*/
|
|
11538
10642
|
|
|
11539
|
-
|
|
11540
|
-
|
|
11541
|
-
|
|
11542
|
-
|
|
11543
|
-
}
|
|
10643
|
+
const parse = (input, options) => {
|
|
10644
|
+
if (typeof input !== 'string') {
|
|
10645
|
+
throw new TypeError('Expected a string');
|
|
10646
|
+
}
|
|
11544
10647
|
|
|
11545
|
-
|
|
11546
|
-
};
|
|
10648
|
+
input = REPLACEMENTS[input] || input;
|
|
11547
10649
|
|
|
11548
|
-
|
|
11549
|
-
|
|
11550
|
-
* This can significantly speed up processing and has very little downside
|
|
11551
|
-
* impact when none of the fast paths match.
|
|
11552
|
-
*/
|
|
10650
|
+
const opts = { ...options };
|
|
10651
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
11553
10652
|
|
|
11554
|
-
|
|
11555
|
-
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
if (len > max) {
|
|
11559
|
-
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
11560
|
-
}
|
|
10653
|
+
let len = input.length;
|
|
10654
|
+
if (len > max) {
|
|
10655
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
10656
|
+
}
|
|
11561
10657
|
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
|
|
11565
|
-
|
|
11566
|
-
|
|
11567
|
-
|
|
11568
|
-
|
|
11569
|
-
|
|
11570
|
-
|
|
11571
|
-
|
|
11572
|
-
|
|
11573
|
-
|
|
11574
|
-
|
|
11575
|
-
|
|
11576
|
-
|
|
11577
|
-
|
|
11578
|
-
|
|
11579
|
-
|
|
11580
|
-
|
|
11581
|
-
|
|
11582
|
-
|
|
11583
|
-
|
|
11584
|
-
|
|
11585
|
-
|
|
11586
|
-
|
|
10658
|
+
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
10659
|
+
const tokens = [bos];
|
|
10660
|
+
|
|
10661
|
+
const capture = opts.capture ? '' : '?:';
|
|
10662
|
+
const win32 = utils.isWindows(options);
|
|
10663
|
+
|
|
10664
|
+
// create constants based on platform, for windows or posix
|
|
10665
|
+
const PLATFORM_CHARS = constants.globChars(win32);
|
|
10666
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
10667
|
+
|
|
10668
|
+
const {
|
|
10669
|
+
DOT_LITERAL,
|
|
10670
|
+
PLUS_LITERAL,
|
|
10671
|
+
SLASH_LITERAL,
|
|
10672
|
+
ONE_CHAR,
|
|
10673
|
+
DOTS_SLASH,
|
|
10674
|
+
NO_DOT,
|
|
10675
|
+
NO_DOT_SLASH,
|
|
10676
|
+
NO_DOTS_SLASH,
|
|
10677
|
+
QMARK,
|
|
10678
|
+
QMARK_NO_DOT,
|
|
10679
|
+
STAR,
|
|
10680
|
+
START_ANCHOR
|
|
10681
|
+
} = PLATFORM_CHARS;
|
|
10682
|
+
|
|
10683
|
+
const globstar = opts => {
|
|
10684
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
10685
|
+
};
|
|
10686
|
+
|
|
10687
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
10688
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
10689
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
10690
|
+
|
|
10691
|
+
if (opts.capture) {
|
|
10692
|
+
star = `(${star})`;
|
|
10693
|
+
}
|
|
11587
10694
|
|
|
11588
|
-
|
|
11589
|
-
|
|
11590
|
-
|
|
11591
|
-
|
|
10695
|
+
// minimatch options support
|
|
10696
|
+
if (typeof opts.noext === 'boolean') {
|
|
10697
|
+
opts.noextglob = opts.noext;
|
|
10698
|
+
}
|
|
11592
10699
|
|
|
11593
|
-
|
|
11594
|
-
|
|
11595
|
-
|
|
11596
|
-
|
|
10700
|
+
const state = {
|
|
10701
|
+
input,
|
|
10702
|
+
index: -1,
|
|
10703
|
+
start: 0,
|
|
10704
|
+
dot: opts.dot === true,
|
|
10705
|
+
consumed: '',
|
|
10706
|
+
output: '',
|
|
10707
|
+
prefix: '',
|
|
10708
|
+
backtrack: false,
|
|
10709
|
+
negated: false,
|
|
10710
|
+
brackets: 0,
|
|
10711
|
+
braces: 0,
|
|
10712
|
+
parens: 0,
|
|
10713
|
+
quotes: 0,
|
|
10714
|
+
globstar: false,
|
|
10715
|
+
tokens
|
|
10716
|
+
};
|
|
10717
|
+
|
|
10718
|
+
input = utils.removePrefix(input, state);
|
|
10719
|
+
len = input.length;
|
|
10720
|
+
|
|
10721
|
+
const extglobs = [];
|
|
10722
|
+
const braces = [];
|
|
10723
|
+
const stack = [];
|
|
10724
|
+
let prev = bos;
|
|
10725
|
+
let value;
|
|
10726
|
+
|
|
10727
|
+
/**
|
|
10728
|
+
* Tokenizing helpers
|
|
10729
|
+
*/
|
|
10730
|
+
|
|
10731
|
+
const eos = () => state.index === len - 1;
|
|
10732
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
10733
|
+
const advance = state.advance = () => input[++state.index] || '';
|
|
10734
|
+
const remaining = () => input.slice(state.index + 1);
|
|
10735
|
+
const consume = (value = '', num = 0) => {
|
|
10736
|
+
state.consumed += value;
|
|
10737
|
+
state.index += num;
|
|
10738
|
+
};
|
|
10739
|
+
|
|
10740
|
+
const append = token => {
|
|
10741
|
+
state.output += token.output != null ? token.output : token.value;
|
|
10742
|
+
consume(token.value);
|
|
10743
|
+
};
|
|
10744
|
+
|
|
10745
|
+
const negate = () => {
|
|
10746
|
+
let count = 1;
|
|
10747
|
+
|
|
10748
|
+
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
10749
|
+
advance();
|
|
10750
|
+
state.start++;
|
|
10751
|
+
count++;
|
|
10752
|
+
}
|
|
10753
|
+
|
|
10754
|
+
if (count % 2 === 0) {
|
|
10755
|
+
return false;
|
|
10756
|
+
}
|
|
10757
|
+
|
|
10758
|
+
state.negated = true;
|
|
10759
|
+
state.start++;
|
|
10760
|
+
return true;
|
|
10761
|
+
};
|
|
10762
|
+
|
|
10763
|
+
const increment = type => {
|
|
10764
|
+
state[type]++;
|
|
10765
|
+
stack.push(type);
|
|
10766
|
+
};
|
|
10767
|
+
|
|
10768
|
+
const decrement = type => {
|
|
10769
|
+
state[type]--;
|
|
10770
|
+
stack.pop();
|
|
10771
|
+
};
|
|
10772
|
+
|
|
10773
|
+
/**
|
|
10774
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
10775
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
10776
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
10777
|
+
* characters are plain text. This improves performance and simplifies
|
|
10778
|
+
* lookbehinds.
|
|
10779
|
+
*/
|
|
10780
|
+
|
|
10781
|
+
const push = tok => {
|
|
10782
|
+
if (prev.type === 'globstar') {
|
|
10783
|
+
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
10784
|
+
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
10785
|
+
|
|
10786
|
+
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
10787
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
10788
|
+
prev.type = 'star';
|
|
10789
|
+
prev.value = '*';
|
|
10790
|
+
prev.output = star;
|
|
10791
|
+
state.output += prev.output;
|
|
10792
|
+
}
|
|
10793
|
+
}
|
|
10794
|
+
|
|
10795
|
+
if (extglobs.length && tok.type !== 'paren') {
|
|
10796
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
10797
|
+
}
|
|
10798
|
+
|
|
10799
|
+
if (tok.value || tok.output) append(tok);
|
|
10800
|
+
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
10801
|
+
prev.value += tok.value;
|
|
10802
|
+
prev.output = (prev.output || '') + tok.value;
|
|
10803
|
+
return;
|
|
10804
|
+
}
|
|
10805
|
+
|
|
10806
|
+
tok.prev = prev;
|
|
10807
|
+
tokens.push(tok);
|
|
10808
|
+
prev = tok;
|
|
10809
|
+
};
|
|
10810
|
+
|
|
10811
|
+
const extglobOpen = (type, value) => {
|
|
10812
|
+
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
10813
|
+
|
|
10814
|
+
token.prev = prev;
|
|
10815
|
+
token.parens = state.parens;
|
|
10816
|
+
token.output = state.output;
|
|
10817
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
10818
|
+
|
|
10819
|
+
increment('parens');
|
|
10820
|
+
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
10821
|
+
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
10822
|
+
extglobs.push(token);
|
|
10823
|
+
};
|
|
10824
|
+
|
|
10825
|
+
const extglobClose = token => {
|
|
10826
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
10827
|
+
let rest;
|
|
10828
|
+
|
|
10829
|
+
if (token.type === 'negate') {
|
|
10830
|
+
let extglobStar = star;
|
|
10831
|
+
|
|
10832
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
10833
|
+
extglobStar = globstar(opts);
|
|
10834
|
+
}
|
|
10835
|
+
|
|
10836
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
10837
|
+
output = token.close = `)$))${extglobStar}`;
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10840
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
10841
|
+
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
10842
|
+
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
10843
|
+
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
10844
|
+
//
|
|
10845
|
+
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
10846
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
10847
|
+
|
|
10848
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
10849
|
+
}
|
|
10850
|
+
|
|
10851
|
+
if (token.prev.type === 'bos') {
|
|
10852
|
+
state.negatedExtglob = true;
|
|
10853
|
+
}
|
|
10854
|
+
}
|
|
10855
|
+
|
|
10856
|
+
push({ type: 'paren', extglob: true, value, output });
|
|
10857
|
+
decrement('parens');
|
|
10858
|
+
};
|
|
10859
|
+
|
|
10860
|
+
/**
|
|
10861
|
+
* Fast paths
|
|
10862
|
+
*/
|
|
10863
|
+
|
|
10864
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
10865
|
+
let backslashes = false;
|
|
10866
|
+
|
|
10867
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
10868
|
+
if (first === '\\') {
|
|
10869
|
+
backslashes = true;
|
|
10870
|
+
return m;
|
|
10871
|
+
}
|
|
10872
|
+
|
|
10873
|
+
if (first === '?') {
|
|
10874
|
+
if (esc) {
|
|
10875
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
10876
|
+
}
|
|
10877
|
+
if (index === 0) {
|
|
10878
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
10879
|
+
}
|
|
10880
|
+
return QMARK.repeat(chars.length);
|
|
10881
|
+
}
|
|
10882
|
+
|
|
10883
|
+
if (first === '.') {
|
|
10884
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
10885
|
+
}
|
|
10886
|
+
|
|
10887
|
+
if (first === '*') {
|
|
10888
|
+
if (esc) {
|
|
10889
|
+
return esc + first + (rest ? star : '');
|
|
10890
|
+
}
|
|
10891
|
+
return star;
|
|
10892
|
+
}
|
|
10893
|
+
return esc ? m : `\\${m}`;
|
|
10894
|
+
});
|
|
10895
|
+
|
|
10896
|
+
if (backslashes === true) {
|
|
10897
|
+
if (opts.unescape === true) {
|
|
10898
|
+
output = output.replace(/\\/g, '');
|
|
10899
|
+
} else {
|
|
10900
|
+
output = output.replace(/\\+/g, m => {
|
|
10901
|
+
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
10902
|
+
});
|
|
10903
|
+
}
|
|
10904
|
+
}
|
|
10905
|
+
|
|
10906
|
+
if (output === input && opts.contains === true) {
|
|
10907
|
+
state.output = input;
|
|
10908
|
+
return state;
|
|
10909
|
+
}
|
|
10910
|
+
|
|
10911
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
10912
|
+
return state;
|
|
10913
|
+
}
|
|
11597
10914
|
|
|
11598
|
-
|
|
11599
|
-
|
|
10915
|
+
/**
|
|
10916
|
+
* Tokenize input until we reach end-of-string
|
|
10917
|
+
*/
|
|
10918
|
+
|
|
10919
|
+
while (!eos()) {
|
|
10920
|
+
value = advance();
|
|
10921
|
+
|
|
10922
|
+
if (value === '\u0000') {
|
|
10923
|
+
continue;
|
|
10924
|
+
}
|
|
10925
|
+
|
|
10926
|
+
/**
|
|
10927
|
+
* Escaped characters
|
|
10928
|
+
*/
|
|
10929
|
+
|
|
10930
|
+
if (value === '\\') {
|
|
10931
|
+
const next = peek();
|
|
10932
|
+
|
|
10933
|
+
if (next === '/' && opts.bash !== true) {
|
|
10934
|
+
continue;
|
|
10935
|
+
}
|
|
10936
|
+
|
|
10937
|
+
if (next === '.' || next === ';') {
|
|
10938
|
+
continue;
|
|
10939
|
+
}
|
|
10940
|
+
|
|
10941
|
+
if (!next) {
|
|
10942
|
+
value += '\\';
|
|
10943
|
+
push({ type: 'text', value });
|
|
10944
|
+
continue;
|
|
10945
|
+
}
|
|
10946
|
+
|
|
10947
|
+
// collapse slashes to reduce potential for exploits
|
|
10948
|
+
const match = /^\\+/.exec(remaining());
|
|
10949
|
+
let slashes = 0;
|
|
10950
|
+
|
|
10951
|
+
if (match && match[0].length > 2) {
|
|
10952
|
+
slashes = match[0].length;
|
|
10953
|
+
state.index += slashes;
|
|
10954
|
+
if (slashes % 2 !== 0) {
|
|
10955
|
+
value += '\\';
|
|
10956
|
+
}
|
|
10957
|
+
}
|
|
10958
|
+
|
|
10959
|
+
if (opts.unescape === true) {
|
|
10960
|
+
value = advance();
|
|
10961
|
+
} else {
|
|
10962
|
+
value += advance();
|
|
10963
|
+
}
|
|
10964
|
+
|
|
10965
|
+
if (state.brackets === 0) {
|
|
10966
|
+
push({ type: 'text', value });
|
|
10967
|
+
continue;
|
|
10968
|
+
}
|
|
10969
|
+
}
|
|
10970
|
+
|
|
10971
|
+
/**
|
|
10972
|
+
* If we're inside a regex character class, continue
|
|
10973
|
+
* until we reach the closing bracket.
|
|
10974
|
+
*/
|
|
10975
|
+
|
|
10976
|
+
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
10977
|
+
if (opts.posix !== false && value === ':') {
|
|
10978
|
+
const inner = prev.value.slice(1);
|
|
10979
|
+
if (inner.includes('[')) {
|
|
10980
|
+
prev.posix = true;
|
|
10981
|
+
|
|
10982
|
+
if (inner.includes(':')) {
|
|
10983
|
+
const idx = prev.value.lastIndexOf('[');
|
|
10984
|
+
const pre = prev.value.slice(0, idx);
|
|
10985
|
+
const rest = prev.value.slice(idx + 2);
|
|
10986
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
10987
|
+
if (posix) {
|
|
10988
|
+
prev.value = pre + posix;
|
|
10989
|
+
state.backtrack = true;
|
|
10990
|
+
advance();
|
|
10991
|
+
|
|
10992
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
10993
|
+
bos.output = ONE_CHAR;
|
|
10994
|
+
}
|
|
10995
|
+
continue;
|
|
10996
|
+
}
|
|
10997
|
+
}
|
|
10998
|
+
}
|
|
10999
|
+
}
|
|
11000
|
+
|
|
11001
|
+
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
11002
|
+
value = `\\${value}`;
|
|
11003
|
+
}
|
|
11004
|
+
|
|
11005
|
+
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
11006
|
+
value = `\\${value}`;
|
|
11007
|
+
}
|
|
11008
|
+
|
|
11009
|
+
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
11010
|
+
value = '^';
|
|
11011
|
+
}
|
|
11012
|
+
|
|
11013
|
+
prev.value += value;
|
|
11014
|
+
append({ value });
|
|
11015
|
+
continue;
|
|
11016
|
+
}
|
|
11017
|
+
|
|
11018
|
+
/**
|
|
11019
|
+
* If we're inside a quoted string, continue
|
|
11020
|
+
* until we reach the closing double quote.
|
|
11021
|
+
*/
|
|
11022
|
+
|
|
11023
|
+
if (state.quotes === 1 && value !== '"') {
|
|
11024
|
+
value = utils.escapeRegex(value);
|
|
11025
|
+
prev.value += value;
|
|
11026
|
+
append({ value });
|
|
11027
|
+
continue;
|
|
11028
|
+
}
|
|
11029
|
+
|
|
11030
|
+
/**
|
|
11031
|
+
* Double quotes
|
|
11032
|
+
*/
|
|
11033
|
+
|
|
11034
|
+
if (value === '"') {
|
|
11035
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
11036
|
+
if (opts.keepQuotes === true) {
|
|
11037
|
+
push({ type: 'text', value });
|
|
11038
|
+
}
|
|
11039
|
+
continue;
|
|
11040
|
+
}
|
|
11041
|
+
|
|
11042
|
+
/**
|
|
11043
|
+
* Parentheses
|
|
11044
|
+
*/
|
|
11045
|
+
|
|
11046
|
+
if (value === '(') {
|
|
11047
|
+
increment('parens');
|
|
11048
|
+
push({ type: 'paren', value });
|
|
11049
|
+
continue;
|
|
11050
|
+
}
|
|
11051
|
+
|
|
11052
|
+
if (value === ')') {
|
|
11053
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
11054
|
+
throw new SyntaxError(syntaxError('opening', '('));
|
|
11055
|
+
}
|
|
11056
|
+
|
|
11057
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
11058
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
11059
|
+
extglobClose(extglobs.pop());
|
|
11060
|
+
continue;
|
|
11061
|
+
}
|
|
11062
|
+
|
|
11063
|
+
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
11064
|
+
decrement('parens');
|
|
11065
|
+
continue;
|
|
11066
|
+
}
|
|
11067
|
+
|
|
11068
|
+
/**
|
|
11069
|
+
* Square brackets
|
|
11070
|
+
*/
|
|
11071
|
+
|
|
11072
|
+
if (value === '[') {
|
|
11073
|
+
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
11074
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
11075
|
+
throw new SyntaxError(syntaxError('closing', ']'));
|
|
11076
|
+
}
|
|
11077
|
+
|
|
11078
|
+
value = `\\${value}`;
|
|
11079
|
+
} else {
|
|
11080
|
+
increment('brackets');
|
|
11081
|
+
}
|
|
11082
|
+
|
|
11083
|
+
push({ type: 'bracket', value });
|
|
11084
|
+
continue;
|
|
11085
|
+
}
|
|
11086
|
+
|
|
11087
|
+
if (value === ']') {
|
|
11088
|
+
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
11089
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
11090
|
+
continue;
|
|
11091
|
+
}
|
|
11092
|
+
|
|
11093
|
+
if (state.brackets === 0) {
|
|
11094
|
+
if (opts.strictBrackets === true) {
|
|
11095
|
+
throw new SyntaxError(syntaxError('opening', '['));
|
|
11096
|
+
}
|
|
11097
|
+
|
|
11098
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
11099
|
+
continue;
|
|
11100
|
+
}
|
|
11101
|
+
|
|
11102
|
+
decrement('brackets');
|
|
11103
|
+
|
|
11104
|
+
const prevValue = prev.value.slice(1);
|
|
11105
|
+
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
11106
|
+
value = `/${value}`;
|
|
11107
|
+
}
|
|
11108
|
+
|
|
11109
|
+
prev.value += value;
|
|
11110
|
+
append({ value });
|
|
11111
|
+
|
|
11112
|
+
// when literal brackets are explicitly disabled
|
|
11113
|
+
// assume we should match with a regex character class
|
|
11114
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
11115
|
+
continue;
|
|
11116
|
+
}
|
|
11117
|
+
|
|
11118
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
11119
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
11120
|
+
|
|
11121
|
+
// when literal brackets are explicitly enabled
|
|
11122
|
+
// assume we should escape the brackets to match literal characters
|
|
11123
|
+
if (opts.literalBrackets === true) {
|
|
11124
|
+
state.output += escaped;
|
|
11125
|
+
prev.value = escaped;
|
|
11126
|
+
continue;
|
|
11127
|
+
}
|
|
11128
|
+
|
|
11129
|
+
// when the user specifies nothing, try to match both
|
|
11130
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
11131
|
+
state.output += prev.value;
|
|
11132
|
+
continue;
|
|
11133
|
+
}
|
|
11134
|
+
|
|
11135
|
+
/**
|
|
11136
|
+
* Braces
|
|
11137
|
+
*/
|
|
11138
|
+
|
|
11139
|
+
if (value === '{' && opts.nobrace !== true) {
|
|
11140
|
+
increment('braces');
|
|
11141
|
+
|
|
11142
|
+
const open = {
|
|
11143
|
+
type: 'brace',
|
|
11144
|
+
value,
|
|
11145
|
+
output: '(',
|
|
11146
|
+
outputIndex: state.output.length,
|
|
11147
|
+
tokensIndex: state.tokens.length
|
|
11148
|
+
};
|
|
11149
|
+
|
|
11150
|
+
braces.push(open);
|
|
11151
|
+
push(open);
|
|
11152
|
+
continue;
|
|
11153
|
+
}
|
|
11154
|
+
|
|
11155
|
+
if (value === '}') {
|
|
11156
|
+
const brace = braces[braces.length - 1];
|
|
11157
|
+
|
|
11158
|
+
if (opts.nobrace === true || !brace) {
|
|
11159
|
+
push({ type: 'text', value, output: value });
|
|
11160
|
+
continue;
|
|
11161
|
+
}
|
|
11162
|
+
|
|
11163
|
+
let output = ')';
|
|
11164
|
+
|
|
11165
|
+
if (brace.dots === true) {
|
|
11166
|
+
const arr = tokens.slice();
|
|
11167
|
+
const range = [];
|
|
11168
|
+
|
|
11169
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
11170
|
+
tokens.pop();
|
|
11171
|
+
if (arr[i].type === 'brace') {
|
|
11172
|
+
break;
|
|
11173
|
+
}
|
|
11174
|
+
if (arr[i].type !== 'dots') {
|
|
11175
|
+
range.unshift(arr[i].value);
|
|
11176
|
+
}
|
|
11177
|
+
}
|
|
11178
|
+
|
|
11179
|
+
output = expandRange(range, opts);
|
|
11180
|
+
state.backtrack = true;
|
|
11181
|
+
}
|
|
11182
|
+
|
|
11183
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
11184
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
11185
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
11186
|
+
brace.value = brace.output = '\\{';
|
|
11187
|
+
value = output = '\\}';
|
|
11188
|
+
state.output = out;
|
|
11189
|
+
for (const t of toks) {
|
|
11190
|
+
state.output += (t.output || t.value);
|
|
11191
|
+
}
|
|
11192
|
+
}
|
|
11193
|
+
|
|
11194
|
+
push({ type: 'brace', value, output });
|
|
11195
|
+
decrement('braces');
|
|
11196
|
+
braces.pop();
|
|
11197
|
+
continue;
|
|
11198
|
+
}
|
|
11199
|
+
|
|
11200
|
+
/**
|
|
11201
|
+
* Pipes
|
|
11202
|
+
*/
|
|
11203
|
+
|
|
11204
|
+
if (value === '|') {
|
|
11205
|
+
if (extglobs.length > 0) {
|
|
11206
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
11207
|
+
}
|
|
11208
|
+
push({ type: 'text', value });
|
|
11209
|
+
continue;
|
|
11210
|
+
}
|
|
11211
|
+
|
|
11212
|
+
/**
|
|
11213
|
+
* Commas
|
|
11214
|
+
*/
|
|
11215
|
+
|
|
11216
|
+
if (value === ',') {
|
|
11217
|
+
let output = value;
|
|
11218
|
+
|
|
11219
|
+
const brace = braces[braces.length - 1];
|
|
11220
|
+
if (brace && stack[stack.length - 1] === 'braces') {
|
|
11221
|
+
brace.comma = true;
|
|
11222
|
+
output = '|';
|
|
11223
|
+
}
|
|
11224
|
+
|
|
11225
|
+
push({ type: 'comma', value, output });
|
|
11226
|
+
continue;
|
|
11227
|
+
}
|
|
11228
|
+
|
|
11229
|
+
/**
|
|
11230
|
+
* Slashes
|
|
11231
|
+
*/
|
|
11232
|
+
|
|
11233
|
+
if (value === '/') {
|
|
11234
|
+
// if the beginning of the glob is "./", advance the start
|
|
11235
|
+
// to the current index, and don't add the "./" characters
|
|
11236
|
+
// to the state. This greatly simplifies lookbehinds when
|
|
11237
|
+
// checking for BOS characters like "!" and "." (not "./")
|
|
11238
|
+
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
11239
|
+
state.start = state.index + 1;
|
|
11240
|
+
state.consumed = '';
|
|
11241
|
+
state.output = '';
|
|
11242
|
+
tokens.pop();
|
|
11243
|
+
prev = bos; // reset "prev" to the first token
|
|
11244
|
+
continue;
|
|
11245
|
+
}
|
|
11246
|
+
|
|
11247
|
+
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
11248
|
+
continue;
|
|
11249
|
+
}
|
|
11250
|
+
|
|
11251
|
+
/**
|
|
11252
|
+
* Dots
|
|
11253
|
+
*/
|
|
11254
|
+
|
|
11255
|
+
if (value === '.') {
|
|
11256
|
+
if (state.braces > 0 && prev.type === 'dot') {
|
|
11257
|
+
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
11258
|
+
const brace = braces[braces.length - 1];
|
|
11259
|
+
prev.type = 'dots';
|
|
11260
|
+
prev.output += value;
|
|
11261
|
+
prev.value += value;
|
|
11262
|
+
brace.dots = true;
|
|
11263
|
+
continue;
|
|
11264
|
+
}
|
|
11265
|
+
|
|
11266
|
+
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
11267
|
+
push({ type: 'text', value, output: DOT_LITERAL });
|
|
11268
|
+
continue;
|
|
11269
|
+
}
|
|
11270
|
+
|
|
11271
|
+
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
11272
|
+
continue;
|
|
11273
|
+
}
|
|
11274
|
+
|
|
11275
|
+
/**
|
|
11276
|
+
* Question marks
|
|
11277
|
+
*/
|
|
11278
|
+
|
|
11279
|
+
if (value === '?') {
|
|
11280
|
+
const isGroup = prev && prev.value === '(';
|
|
11281
|
+
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
11282
|
+
extglobOpen('qmark', value);
|
|
11283
|
+
continue;
|
|
11284
|
+
}
|
|
11285
|
+
|
|
11286
|
+
if (prev && prev.type === 'paren') {
|
|
11287
|
+
const next = peek();
|
|
11288
|
+
let output = value;
|
|
11289
|
+
|
|
11290
|
+
if (next === '<' && !utils.supportsLookbehinds()) {
|
|
11291
|
+
throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
|
11292
|
+
}
|
|
11293
|
+
|
|
11294
|
+
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
11295
|
+
output = `\\${value}`;
|
|
11296
|
+
}
|
|
11297
|
+
|
|
11298
|
+
push({ type: 'text', value, output });
|
|
11299
|
+
continue;
|
|
11300
|
+
}
|
|
11301
|
+
|
|
11302
|
+
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
11303
|
+
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
11304
|
+
continue;
|
|
11305
|
+
}
|
|
11306
|
+
|
|
11307
|
+
push({ type: 'qmark', value, output: QMARK });
|
|
11308
|
+
continue;
|
|
11309
|
+
}
|
|
11310
|
+
|
|
11311
|
+
/**
|
|
11312
|
+
* Exclamation
|
|
11313
|
+
*/
|
|
11314
|
+
|
|
11315
|
+
if (value === '!') {
|
|
11316
|
+
if (opts.noextglob !== true && peek() === '(') {
|
|
11317
|
+
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
11318
|
+
extglobOpen('negate', value);
|
|
11319
|
+
continue;
|
|
11320
|
+
}
|
|
11321
|
+
}
|
|
11322
|
+
|
|
11323
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
11324
|
+
negate();
|
|
11325
|
+
continue;
|
|
11326
|
+
}
|
|
11327
|
+
}
|
|
11328
|
+
|
|
11329
|
+
/**
|
|
11330
|
+
* Plus
|
|
11331
|
+
*/
|
|
11332
|
+
|
|
11333
|
+
if (value === '+') {
|
|
11334
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
11335
|
+
extglobOpen('plus', value);
|
|
11336
|
+
continue;
|
|
11337
|
+
}
|
|
11338
|
+
|
|
11339
|
+
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
11340
|
+
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
11341
|
+
continue;
|
|
11342
|
+
}
|
|
11343
|
+
|
|
11344
|
+
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
11345
|
+
push({ type: 'plus', value });
|
|
11346
|
+
continue;
|
|
11347
|
+
}
|
|
11348
|
+
|
|
11349
|
+
push({ type: 'plus', value: PLUS_LITERAL });
|
|
11350
|
+
continue;
|
|
11351
|
+
}
|
|
11352
|
+
|
|
11353
|
+
/**
|
|
11354
|
+
* Plain text
|
|
11355
|
+
*/
|
|
11356
|
+
|
|
11357
|
+
if (value === '@') {
|
|
11358
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
11359
|
+
push({ type: 'at', extglob: true, value, output: '' });
|
|
11360
|
+
continue;
|
|
11361
|
+
}
|
|
11362
|
+
|
|
11363
|
+
push({ type: 'text', value });
|
|
11364
|
+
continue;
|
|
11365
|
+
}
|
|
11366
|
+
|
|
11367
|
+
/**
|
|
11368
|
+
* Plain text
|
|
11369
|
+
*/
|
|
11370
|
+
|
|
11371
|
+
if (value !== '*') {
|
|
11372
|
+
if (value === '$' || value === '^') {
|
|
11373
|
+
value = `\\${value}`;
|
|
11374
|
+
}
|
|
11375
|
+
|
|
11376
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
11377
|
+
if (match) {
|
|
11378
|
+
value += match[0];
|
|
11379
|
+
state.index += match[0].length;
|
|
11380
|
+
}
|
|
11381
|
+
|
|
11382
|
+
push({ type: 'text', value });
|
|
11383
|
+
continue;
|
|
11384
|
+
}
|
|
11385
|
+
|
|
11386
|
+
/**
|
|
11387
|
+
* Stars
|
|
11388
|
+
*/
|
|
11389
|
+
|
|
11390
|
+
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
11391
|
+
prev.type = 'star';
|
|
11392
|
+
prev.star = true;
|
|
11393
|
+
prev.value += value;
|
|
11394
|
+
prev.output = star;
|
|
11395
|
+
state.backtrack = true;
|
|
11396
|
+
state.globstar = true;
|
|
11397
|
+
consume(value);
|
|
11398
|
+
continue;
|
|
11399
|
+
}
|
|
11400
|
+
|
|
11401
|
+
let rest = remaining();
|
|
11402
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
11403
|
+
extglobOpen('star', value);
|
|
11404
|
+
continue;
|
|
11405
|
+
}
|
|
11406
|
+
|
|
11407
|
+
if (prev.type === 'star') {
|
|
11408
|
+
if (opts.noglobstar === true) {
|
|
11409
|
+
consume(value);
|
|
11410
|
+
continue;
|
|
11411
|
+
}
|
|
11412
|
+
|
|
11413
|
+
const prior = prev.prev;
|
|
11414
|
+
const before = prior.prev;
|
|
11415
|
+
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
11416
|
+
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
11417
|
+
|
|
11418
|
+
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
11419
|
+
push({ type: 'star', value, output: '' });
|
|
11420
|
+
continue;
|
|
11421
|
+
}
|
|
11422
|
+
|
|
11423
|
+
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
11424
|
+
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
11425
|
+
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
11426
|
+
push({ type: 'star', value, output: '' });
|
|
11427
|
+
continue;
|
|
11428
|
+
}
|
|
11429
|
+
|
|
11430
|
+
// strip consecutive `/**/`
|
|
11431
|
+
while (rest.slice(0, 3) === '/**') {
|
|
11432
|
+
const after = input[state.index + 4];
|
|
11433
|
+
if (after && after !== '/') {
|
|
11434
|
+
break;
|
|
11435
|
+
}
|
|
11436
|
+
rest = rest.slice(3);
|
|
11437
|
+
consume('/**', 3);
|
|
11438
|
+
}
|
|
11439
|
+
|
|
11440
|
+
if (prior.type === 'bos' && eos()) {
|
|
11441
|
+
prev.type = 'globstar';
|
|
11442
|
+
prev.value += value;
|
|
11443
|
+
prev.output = globstar(opts);
|
|
11444
|
+
state.output = prev.output;
|
|
11445
|
+
state.globstar = true;
|
|
11446
|
+
consume(value);
|
|
11447
|
+
continue;
|
|
11448
|
+
}
|
|
11449
|
+
|
|
11450
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
11451
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
11452
|
+
prior.output = `(?:${prior.output}`;
|
|
11453
|
+
|
|
11454
|
+
prev.type = 'globstar';
|
|
11455
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
11456
|
+
prev.value += value;
|
|
11457
|
+
state.globstar = true;
|
|
11458
|
+
state.output += prior.output + prev.output;
|
|
11459
|
+
consume(value);
|
|
11460
|
+
continue;
|
|
11461
|
+
}
|
|
11462
|
+
|
|
11463
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
11464
|
+
const end = rest[1] !== void 0 ? '|$' : '';
|
|
11465
|
+
|
|
11466
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
11467
|
+
prior.output = `(?:${prior.output}`;
|
|
11468
|
+
|
|
11469
|
+
prev.type = 'globstar';
|
|
11470
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
11471
|
+
prev.value += value;
|
|
11472
|
+
|
|
11473
|
+
state.output += prior.output + prev.output;
|
|
11474
|
+
state.globstar = true;
|
|
11475
|
+
|
|
11476
|
+
consume(value + advance());
|
|
11477
|
+
|
|
11478
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
11479
|
+
continue;
|
|
11480
|
+
}
|
|
11481
|
+
|
|
11482
|
+
if (prior.type === 'bos' && rest[0] === '/') {
|
|
11483
|
+
prev.type = 'globstar';
|
|
11484
|
+
prev.value += value;
|
|
11485
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
11486
|
+
state.output = prev.output;
|
|
11487
|
+
state.globstar = true;
|
|
11488
|
+
consume(value + advance());
|
|
11489
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
11490
|
+
continue;
|
|
11491
|
+
}
|
|
11492
|
+
|
|
11493
|
+
// remove single star from output
|
|
11494
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
11495
|
+
|
|
11496
|
+
// reset previous token to globstar
|
|
11497
|
+
prev.type = 'globstar';
|
|
11498
|
+
prev.output = globstar(opts);
|
|
11499
|
+
prev.value += value;
|
|
11500
|
+
|
|
11501
|
+
// reset output with globstar
|
|
11502
|
+
state.output += prev.output;
|
|
11503
|
+
state.globstar = true;
|
|
11504
|
+
consume(value);
|
|
11505
|
+
continue;
|
|
11506
|
+
}
|
|
11507
|
+
|
|
11508
|
+
const token = { type: 'star', value, output: star };
|
|
11509
|
+
|
|
11510
|
+
if (opts.bash === true) {
|
|
11511
|
+
token.output = '.*?';
|
|
11512
|
+
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
11513
|
+
token.output = nodot + token.output;
|
|
11514
|
+
}
|
|
11515
|
+
push(token);
|
|
11516
|
+
continue;
|
|
11517
|
+
}
|
|
11518
|
+
|
|
11519
|
+
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
11520
|
+
token.output = value;
|
|
11521
|
+
push(token);
|
|
11522
|
+
continue;
|
|
11523
|
+
}
|
|
11524
|
+
|
|
11525
|
+
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
11526
|
+
if (prev.type === 'dot') {
|
|
11527
|
+
state.output += NO_DOT_SLASH;
|
|
11528
|
+
prev.output += NO_DOT_SLASH;
|
|
11529
|
+
|
|
11530
|
+
} else if (opts.dot === true) {
|
|
11531
|
+
state.output += NO_DOTS_SLASH;
|
|
11532
|
+
prev.output += NO_DOTS_SLASH;
|
|
11533
|
+
|
|
11534
|
+
} else {
|
|
11535
|
+
state.output += nodot;
|
|
11536
|
+
prev.output += nodot;
|
|
11537
|
+
}
|
|
11538
|
+
|
|
11539
|
+
if (peek() !== '*') {
|
|
11540
|
+
state.output += ONE_CHAR;
|
|
11541
|
+
prev.output += ONE_CHAR;
|
|
11542
|
+
}
|
|
11543
|
+
}
|
|
11544
|
+
|
|
11545
|
+
push(token);
|
|
11546
|
+
}
|
|
11600
11547
|
|
|
11601
|
-
|
|
11602
|
-
|
|
11548
|
+
while (state.brackets > 0) {
|
|
11549
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
11550
|
+
state.output = utils.escapeLast(state.output, '[');
|
|
11551
|
+
decrement('brackets');
|
|
11552
|
+
}
|
|
11603
11553
|
|
|
11604
|
-
|
|
11605
|
-
|
|
11554
|
+
while (state.parens > 0) {
|
|
11555
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
11556
|
+
state.output = utils.escapeLast(state.output, '(');
|
|
11557
|
+
decrement('parens');
|
|
11558
|
+
}
|
|
11606
11559
|
|
|
11607
|
-
|
|
11608
|
-
|
|
11560
|
+
while (state.braces > 0) {
|
|
11561
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
11562
|
+
state.output = utils.escapeLast(state.output, '{');
|
|
11563
|
+
decrement('braces');
|
|
11564
|
+
}
|
|
11609
11565
|
|
|
11610
|
-
|
|
11611
|
-
|
|
11566
|
+
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
11567
|
+
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
11568
|
+
}
|
|
11612
11569
|
|
|
11613
|
-
|
|
11614
|
-
|
|
11570
|
+
// rebuild the output if we had to backtrack at any point
|
|
11571
|
+
if (state.backtrack === true) {
|
|
11572
|
+
state.output = '';
|
|
11615
11573
|
|
|
11616
|
-
|
|
11617
|
-
|
|
11574
|
+
for (const token of state.tokens) {
|
|
11575
|
+
state.output += token.output != null ? token.output : token.value;
|
|
11618
11576
|
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11577
|
+
if (token.suffix) {
|
|
11578
|
+
state.output += token.suffix;
|
|
11579
|
+
}
|
|
11580
|
+
}
|
|
11581
|
+
}
|
|
11622
11582
|
|
|
11623
|
-
|
|
11624
|
-
|
|
11583
|
+
return state;
|
|
11584
|
+
};
|
|
11625
11585
|
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11586
|
+
/**
|
|
11587
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
11588
|
+
* This can significantly speed up processing and has very little downside
|
|
11589
|
+
* impact when none of the fast paths match.
|
|
11590
|
+
*/
|
|
11591
|
+
|
|
11592
|
+
parse.fastpaths = (input, options) => {
|
|
11593
|
+
const opts = { ...options };
|
|
11594
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
11595
|
+
const len = input.length;
|
|
11596
|
+
if (len > max) {
|
|
11597
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
11598
|
+
}
|
|
11630
11599
|
|
|
11631
|
-
|
|
11632
|
-
|
|
11600
|
+
input = REPLACEMENTS[input] || input;
|
|
11601
|
+
const win32 = utils.isWindows(options);
|
|
11602
|
+
|
|
11603
|
+
// create constants based on platform, for windows or posix
|
|
11604
|
+
const {
|
|
11605
|
+
DOT_LITERAL,
|
|
11606
|
+
SLASH_LITERAL,
|
|
11607
|
+
ONE_CHAR,
|
|
11608
|
+
DOTS_SLASH,
|
|
11609
|
+
NO_DOT,
|
|
11610
|
+
NO_DOTS,
|
|
11611
|
+
NO_DOTS_SLASH,
|
|
11612
|
+
STAR,
|
|
11613
|
+
START_ANCHOR
|
|
11614
|
+
} = constants.globChars(win32);
|
|
11615
|
+
|
|
11616
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
11617
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
11618
|
+
const capture = opts.capture ? '' : '?:';
|
|
11619
|
+
const state = { negated: false, prefix: '' };
|
|
11620
|
+
let star = opts.bash === true ? '.*?' : STAR;
|
|
11621
|
+
|
|
11622
|
+
if (opts.capture) {
|
|
11623
|
+
star = `(${star})`;
|
|
11624
|
+
}
|
|
11633
11625
|
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11626
|
+
const globstar = opts => {
|
|
11627
|
+
if (opts.noglobstar === true) return star;
|
|
11628
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
11629
|
+
};
|
|
11637
11630
|
|
|
11638
|
-
|
|
11639
|
-
|
|
11631
|
+
const create = str => {
|
|
11632
|
+
switch (str) {
|
|
11633
|
+
case '*':
|
|
11634
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
11640
11635
|
|
|
11641
|
-
|
|
11636
|
+
case '.*':
|
|
11637
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
11642
11638
|
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
const parse = parse_1;
|
|
11646
|
-
const utils = utils$3;
|
|
11647
|
-
const constants = constants$2;
|
|
11648
|
-
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
11639
|
+
case '*.*':
|
|
11640
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
11649
11641
|
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
* returned function takes a string to match as its first argument,
|
|
11653
|
-
* and returns true if the string is a match. The returned matcher
|
|
11654
|
-
* function also takes a boolean as the second argument that, when true,
|
|
11655
|
-
* returns an object with additional information.
|
|
11656
|
-
*
|
|
11657
|
-
* ```js
|
|
11658
|
-
* const picomatch = require('picomatch');
|
|
11659
|
-
* // picomatch(glob[, options]);
|
|
11660
|
-
*
|
|
11661
|
-
* const isMatch = picomatch('*.!(*a)');
|
|
11662
|
-
* console.log(isMatch('a.a')); //=> false
|
|
11663
|
-
* console.log(isMatch('a.b')); //=> true
|
|
11664
|
-
* ```
|
|
11665
|
-
* @name picomatch
|
|
11666
|
-
* @param {String|Array} `globs` One or more glob patterns.
|
|
11667
|
-
* @param {Object=} `options`
|
|
11668
|
-
* @return {Function=} Returns a matcher function.
|
|
11669
|
-
* @api public
|
|
11670
|
-
*/
|
|
11642
|
+
case '*/*':
|
|
11643
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
11671
11644
|
|
|
11672
|
-
|
|
11673
|
-
|
|
11674
|
-
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
|
11675
|
-
const arrayMatcher = str => {
|
|
11676
|
-
for (const isMatch of fns) {
|
|
11677
|
-
const state = isMatch(str);
|
|
11678
|
-
if (state) return state;
|
|
11679
|
-
}
|
|
11680
|
-
return false;
|
|
11681
|
-
};
|
|
11682
|
-
return arrayMatcher;
|
|
11683
|
-
}
|
|
11645
|
+
case '**':
|
|
11646
|
+
return nodot + globstar(opts);
|
|
11684
11647
|
|
|
11685
|
-
|
|
11648
|
+
case '**/*':
|
|
11649
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
11686
11650
|
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
}
|
|
11651
|
+
case '**/*.*':
|
|
11652
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
11690
11653
|
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
const regex = isState
|
|
11694
|
-
? picomatch$1.compileRe(glob, options)
|
|
11695
|
-
: picomatch$1.makeRe(glob, options, false, true);
|
|
11654
|
+
case '**/.*':
|
|
11655
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
11696
11656
|
|
|
11697
|
-
|
|
11698
|
-
|
|
11657
|
+
default: {
|
|
11658
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
11659
|
+
if (!match) return;
|
|
11699
11660
|
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
11703
|
-
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
|
11704
|
-
}
|
|
11661
|
+
const source = create(match[1]);
|
|
11662
|
+
if (!source) return;
|
|
11705
11663
|
|
|
11706
|
-
|
|
11707
|
-
|
|
11708
|
-
|
|
11664
|
+
return source + DOT_LITERAL + match[2];
|
|
11665
|
+
}
|
|
11666
|
+
}
|
|
11667
|
+
};
|
|
11709
11668
|
|
|
11710
|
-
|
|
11711
|
-
|
|
11712
|
-
}
|
|
11669
|
+
const output = utils.removePrefix(input, state);
|
|
11670
|
+
let source = create(output);
|
|
11713
11671
|
|
|
11714
|
-
|
|
11715
|
-
|
|
11716
|
-
|
|
11717
|
-
}
|
|
11672
|
+
if (source && opts.strictSlashes !== true) {
|
|
11673
|
+
source += `${SLASH_LITERAL}?`;
|
|
11674
|
+
}
|
|
11718
11675
|
|
|
11719
|
-
|
|
11720
|
-
|
|
11721
|
-
opts.onIgnore(result);
|
|
11722
|
-
}
|
|
11723
|
-
result.isMatch = false;
|
|
11724
|
-
return returnObject ? result : false;
|
|
11725
|
-
}
|
|
11676
|
+
return source;
|
|
11677
|
+
};
|
|
11726
11678
|
|
|
11727
|
-
|
|
11728
|
-
|
|
11729
|
-
|
|
11730
|
-
return returnObject ? result : true;
|
|
11731
|
-
};
|
|
11679
|
+
parse_1 = parse;
|
|
11680
|
+
return parse_1;
|
|
11681
|
+
}
|
|
11732
11682
|
|
|
11733
|
-
|
|
11734
|
-
|
|
11735
|
-
}
|
|
11683
|
+
var picomatch_1;
|
|
11684
|
+
var hasRequiredPicomatch$1;
|
|
11736
11685
|
|
|
11737
|
-
|
|
11738
|
-
|
|
11686
|
+
function requirePicomatch$1 () {
|
|
11687
|
+
if (hasRequiredPicomatch$1) return picomatch_1;
|
|
11688
|
+
hasRequiredPicomatch$1 = 1;
|
|
11739
11689
|
|
|
11740
|
-
|
|
11741
|
-
|
|
11742
|
-
|
|
11743
|
-
|
|
11744
|
-
|
|
11745
|
-
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
|
|
11753
|
-
|
|
11754
|
-
|
|
11755
|
-
|
|
11690
|
+
const path = require$$0;
|
|
11691
|
+
const scan = /*@__PURE__*/ requireScan();
|
|
11692
|
+
const parse = /*@__PURE__*/ requireParse();
|
|
11693
|
+
const utils = /*@__PURE__*/ requireUtils();
|
|
11694
|
+
const constants = /*@__PURE__*/ requireConstants();
|
|
11695
|
+
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
11696
|
+
|
|
11697
|
+
/**
|
|
11698
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
11699
|
+
* returned function takes a string to match as its first argument,
|
|
11700
|
+
* and returns true if the string is a match. The returned matcher
|
|
11701
|
+
* function also takes a boolean as the second argument that, when true,
|
|
11702
|
+
* returns an object with additional information.
|
|
11703
|
+
*
|
|
11704
|
+
* ```js
|
|
11705
|
+
* const picomatch = require('picomatch');
|
|
11706
|
+
* // picomatch(glob[, options]);
|
|
11707
|
+
*
|
|
11708
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
11709
|
+
* console.log(isMatch('a.a')); //=> false
|
|
11710
|
+
* console.log(isMatch('a.b')); //=> true
|
|
11711
|
+
* ```
|
|
11712
|
+
* @name picomatch
|
|
11713
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
11714
|
+
* @param {Object=} `options`
|
|
11715
|
+
* @return {Function=} Returns a matcher function.
|
|
11716
|
+
* @api public
|
|
11717
|
+
*/
|
|
11718
|
+
|
|
11719
|
+
const picomatch = (glob, options, returnState = false) => {
|
|
11720
|
+
if (Array.isArray(glob)) {
|
|
11721
|
+
const fns = glob.map(input => picomatch(input, options, returnState));
|
|
11722
|
+
const arrayMatcher = str => {
|
|
11723
|
+
for (const isMatch of fns) {
|
|
11724
|
+
const state = isMatch(str);
|
|
11725
|
+
if (state) return state;
|
|
11726
|
+
}
|
|
11727
|
+
return false;
|
|
11728
|
+
};
|
|
11729
|
+
return arrayMatcher;
|
|
11730
|
+
}
|
|
11756
11731
|
|
|
11757
|
-
|
|
11758
|
-
if (typeof input !== 'string') {
|
|
11759
|
-
throw new TypeError('Expected input to be a string');
|
|
11760
|
-
}
|
|
11732
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
11761
11733
|
|
|
11762
|
-
|
|
11763
|
-
|
|
11764
|
-
|
|
11734
|
+
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
11735
|
+
throw new TypeError('Expected pattern to be a non-empty string');
|
|
11736
|
+
}
|
|
11765
11737
|
|
|
11766
|
-
|
|
11767
|
-
|
|
11768
|
-
|
|
11769
|
-
|
|
11738
|
+
const opts = options || {};
|
|
11739
|
+
const posix = utils.isWindows(options);
|
|
11740
|
+
const regex = isState
|
|
11741
|
+
? picomatch.compileRe(glob, options)
|
|
11742
|
+
: picomatch.makeRe(glob, options, false, true);
|
|
11770
11743
|
|
|
11771
|
-
|
|
11772
|
-
|
|
11773
|
-
match = output === glob;
|
|
11774
|
-
}
|
|
11744
|
+
const state = regex.state;
|
|
11745
|
+
delete regex.state;
|
|
11775
11746
|
|
|
11776
|
-
|
|
11777
|
-
|
|
11778
|
-
|
|
11779
|
-
|
|
11780
|
-
|
|
11781
|
-
}
|
|
11782
|
-
}
|
|
11747
|
+
let isIgnored = () => false;
|
|
11748
|
+
if (opts.ignore) {
|
|
11749
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
11750
|
+
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
|
11751
|
+
}
|
|
11783
11752
|
|
|
11784
|
-
|
|
11785
|
-
};
|
|
11753
|
+
const matcher = (input, returnObject = false) => {
|
|
11754
|
+
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
|
11755
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
11756
|
+
|
|
11757
|
+
if (typeof opts.onResult === 'function') {
|
|
11758
|
+
opts.onResult(result);
|
|
11759
|
+
}
|
|
11760
|
+
|
|
11761
|
+
if (isMatch === false) {
|
|
11762
|
+
result.isMatch = false;
|
|
11763
|
+
return returnObject ? result : false;
|
|
11764
|
+
}
|
|
11765
|
+
|
|
11766
|
+
if (isIgnored(input)) {
|
|
11767
|
+
if (typeof opts.onIgnore === 'function') {
|
|
11768
|
+
opts.onIgnore(result);
|
|
11769
|
+
}
|
|
11770
|
+
result.isMatch = false;
|
|
11771
|
+
return returnObject ? result : false;
|
|
11772
|
+
}
|
|
11773
|
+
|
|
11774
|
+
if (typeof opts.onMatch === 'function') {
|
|
11775
|
+
opts.onMatch(result);
|
|
11776
|
+
}
|
|
11777
|
+
return returnObject ? result : true;
|
|
11778
|
+
};
|
|
11779
|
+
|
|
11780
|
+
if (returnState) {
|
|
11781
|
+
matcher.state = state;
|
|
11782
|
+
}
|
|
11786
11783
|
|
|
11787
|
-
|
|
11788
|
-
|
|
11789
|
-
*
|
|
11790
|
-
* ```js
|
|
11791
|
-
* const picomatch = require('picomatch');
|
|
11792
|
-
* // picomatch.matchBase(input, glob[, options]);
|
|
11793
|
-
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
11794
|
-
* ```
|
|
11795
|
-
* @param {String} `input` String to test.
|
|
11796
|
-
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
11797
|
-
* @return {Boolean}
|
|
11798
|
-
* @api public
|
|
11799
|
-
*/
|
|
11784
|
+
return matcher;
|
|
11785
|
+
};
|
|
11800
11786
|
|
|
11801
|
-
|
|
11802
|
-
|
|
11803
|
-
|
|
11804
|
-
|
|
11787
|
+
/**
|
|
11788
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
11789
|
+
* `picomatch()` function to test the input string.
|
|
11790
|
+
*
|
|
11791
|
+
* ```js
|
|
11792
|
+
* const picomatch = require('picomatch');
|
|
11793
|
+
* // picomatch.test(input, regex[, options]);
|
|
11794
|
+
*
|
|
11795
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
11796
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
11797
|
+
* ```
|
|
11798
|
+
* @param {String} `input` String to test.
|
|
11799
|
+
* @param {RegExp} `regex`
|
|
11800
|
+
* @return {Object} Returns an object with matching info.
|
|
11801
|
+
* @api public
|
|
11802
|
+
*/
|
|
11803
|
+
|
|
11804
|
+
picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
|
11805
|
+
if (typeof input !== 'string') {
|
|
11806
|
+
throw new TypeError('Expected input to be a string');
|
|
11807
|
+
}
|
|
11805
11808
|
|
|
11806
|
-
|
|
11807
|
-
|
|
11808
|
-
|
|
11809
|
-
* ```js
|
|
11810
|
-
* const picomatch = require('picomatch');
|
|
11811
|
-
* // picomatch.isMatch(string, patterns[, options]);
|
|
11812
|
-
*
|
|
11813
|
-
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
11814
|
-
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
11815
|
-
* ```
|
|
11816
|
-
* @param {String|Array} str The string to test.
|
|
11817
|
-
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
11818
|
-
* @param {Object} [options] See available [options](#options).
|
|
11819
|
-
* @return {Boolean} Returns true if any patterns match `str`
|
|
11820
|
-
* @api public
|
|
11821
|
-
*/
|
|
11809
|
+
if (input === '') {
|
|
11810
|
+
return { isMatch: false, output: '' };
|
|
11811
|
+
}
|
|
11822
11812
|
|
|
11823
|
-
|
|
11813
|
+
const opts = options || {};
|
|
11814
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
11815
|
+
let match = input === glob;
|
|
11816
|
+
let output = (match && format) ? format(input) : input;
|
|
11824
11817
|
|
|
11825
|
-
|
|
11826
|
-
|
|
11827
|
-
|
|
11828
|
-
|
|
11829
|
-
* ```js
|
|
11830
|
-
* const picomatch = require('picomatch');
|
|
11831
|
-
* const result = picomatch.parse(pattern[, options]);
|
|
11832
|
-
* ```
|
|
11833
|
-
* @param {String} `pattern`
|
|
11834
|
-
* @param {Object} `options`
|
|
11835
|
-
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
11836
|
-
* @api public
|
|
11837
|
-
*/
|
|
11818
|
+
if (match === false) {
|
|
11819
|
+
output = format ? format(input) : input;
|
|
11820
|
+
match = output === glob;
|
|
11821
|
+
}
|
|
11838
11822
|
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
}
|
|
11823
|
+
if (match === false || opts.capture === true) {
|
|
11824
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
11825
|
+
match = picomatch.matchBase(input, regex, options, posix);
|
|
11826
|
+
} else {
|
|
11827
|
+
match = regex.exec(output);
|
|
11828
|
+
}
|
|
11829
|
+
}
|
|
11843
11830
|
|
|
11844
|
-
|
|
11845
|
-
|
|
11846
|
-
*
|
|
11847
|
-
* ```js
|
|
11848
|
-
* const picomatch = require('picomatch');
|
|
11849
|
-
* // picomatch.scan(input[, options]);
|
|
11850
|
-
*
|
|
11851
|
-
* const result = picomatch.scan('!./foo/*.js');
|
|
11852
|
-
* console.log(result);
|
|
11853
|
-
* { prefix: '!./',
|
|
11854
|
-
* input: '!./foo/*.js',
|
|
11855
|
-
* start: 3,
|
|
11856
|
-
* base: 'foo',
|
|
11857
|
-
* glob: '*.js',
|
|
11858
|
-
* isBrace: false,
|
|
11859
|
-
* isBracket: false,
|
|
11860
|
-
* isGlob: true,
|
|
11861
|
-
* isExtglob: false,
|
|
11862
|
-
* isGlobstar: false,
|
|
11863
|
-
* negated: true }
|
|
11864
|
-
* ```
|
|
11865
|
-
* @param {String} `input` Glob pattern to scan.
|
|
11866
|
-
* @param {Object} `options`
|
|
11867
|
-
* @return {Object} Returns an object with
|
|
11868
|
-
* @api public
|
|
11869
|
-
*/
|
|
11831
|
+
return { isMatch: Boolean(match), match, output };
|
|
11832
|
+
};
|
|
11870
11833
|
|
|
11871
|
-
|
|
11834
|
+
/**
|
|
11835
|
+
* Match the basename of a filepath.
|
|
11836
|
+
*
|
|
11837
|
+
* ```js
|
|
11838
|
+
* const picomatch = require('picomatch');
|
|
11839
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
11840
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
11841
|
+
* ```
|
|
11842
|
+
* @param {String} `input` String to test.
|
|
11843
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
11844
|
+
* @return {Boolean}
|
|
11845
|
+
* @api public
|
|
11846
|
+
*/
|
|
11847
|
+
|
|
11848
|
+
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
11849
|
+
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
|
11850
|
+
return regex.test(path.basename(input));
|
|
11851
|
+
};
|
|
11872
11852
|
|
|
11873
|
-
/**
|
|
11874
|
-
|
|
11875
|
-
|
|
11876
|
-
|
|
11877
|
-
|
|
11878
|
-
|
|
11879
|
-
|
|
11880
|
-
|
|
11881
|
-
|
|
11882
|
-
|
|
11883
|
-
|
|
11853
|
+
/**
|
|
11854
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
11855
|
+
*
|
|
11856
|
+
* ```js
|
|
11857
|
+
* const picomatch = require('picomatch');
|
|
11858
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
11859
|
+
*
|
|
11860
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
11861
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
11862
|
+
* ```
|
|
11863
|
+
* @param {String|Array} str The string to test.
|
|
11864
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
11865
|
+
* @param {Object} [options] See available [options](#options).
|
|
11866
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
11867
|
+
* @api public
|
|
11868
|
+
*/
|
|
11869
|
+
|
|
11870
|
+
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
|
11871
|
+
|
|
11872
|
+
/**
|
|
11873
|
+
* Parse a glob pattern to create the source string for a regular
|
|
11874
|
+
* expression.
|
|
11875
|
+
*
|
|
11876
|
+
* ```js
|
|
11877
|
+
* const picomatch = require('picomatch');
|
|
11878
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
11879
|
+
* ```
|
|
11880
|
+
* @param {String} `pattern`
|
|
11881
|
+
* @param {Object} `options`
|
|
11882
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
11883
|
+
* @api public
|
|
11884
|
+
*/
|
|
11885
|
+
|
|
11886
|
+
picomatch.parse = (pattern, options) => {
|
|
11887
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
|
11888
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
11889
|
+
};
|
|
11884
11890
|
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
|
|
11891
|
+
/**
|
|
11892
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
11893
|
+
*
|
|
11894
|
+
* ```js
|
|
11895
|
+
* const picomatch = require('picomatch');
|
|
11896
|
+
* // picomatch.scan(input[, options]);
|
|
11897
|
+
*
|
|
11898
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
11899
|
+
* console.log(result);
|
|
11900
|
+
* { prefix: '!./',
|
|
11901
|
+
* input: '!./foo/*.js',
|
|
11902
|
+
* start: 3,
|
|
11903
|
+
* base: 'foo',
|
|
11904
|
+
* glob: '*.js',
|
|
11905
|
+
* isBrace: false,
|
|
11906
|
+
* isBracket: false,
|
|
11907
|
+
* isGlob: true,
|
|
11908
|
+
* isExtglob: false,
|
|
11909
|
+
* isGlobstar: false,
|
|
11910
|
+
* negated: true }
|
|
11911
|
+
* ```
|
|
11912
|
+
* @param {String} `input` Glob pattern to scan.
|
|
11913
|
+
* @param {Object} `options`
|
|
11914
|
+
* @return {Object} Returns an object with
|
|
11915
|
+
* @api public
|
|
11916
|
+
*/
|
|
11917
|
+
|
|
11918
|
+
picomatch.scan = (input, options) => scan(input, options);
|
|
11919
|
+
|
|
11920
|
+
/**
|
|
11921
|
+
* Compile a regular expression from the `state` object returned by the
|
|
11922
|
+
* [parse()](#parse) method.
|
|
11923
|
+
*
|
|
11924
|
+
* @param {Object} `state`
|
|
11925
|
+
* @param {Object} `options`
|
|
11926
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
11927
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
11928
|
+
* @return {RegExp}
|
|
11929
|
+
* @api public
|
|
11930
|
+
*/
|
|
11931
|
+
|
|
11932
|
+
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
11933
|
+
if (returnOutput === true) {
|
|
11934
|
+
return state.output;
|
|
11935
|
+
}
|
|
11889
11936
|
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11937
|
+
const opts = options || {};
|
|
11938
|
+
const prepend = opts.contains ? '' : '^';
|
|
11939
|
+
const append = opts.contains ? '' : '$';
|
|
11893
11940
|
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11941
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
11942
|
+
if (state && state.negated === true) {
|
|
11943
|
+
source = `^(?!${source}).*$`;
|
|
11944
|
+
}
|
|
11898
11945
|
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
11946
|
+
const regex = picomatch.toRegex(source, options);
|
|
11947
|
+
if (returnState === true) {
|
|
11948
|
+
regex.state = state;
|
|
11949
|
+
}
|
|
11903
11950
|
|
|
11904
|
-
|
|
11905
|
-
};
|
|
11951
|
+
return regex;
|
|
11952
|
+
};
|
|
11906
11953
|
|
|
11907
|
-
/**
|
|
11908
|
-
|
|
11909
|
-
|
|
11910
|
-
|
|
11911
|
-
|
|
11912
|
-
|
|
11913
|
-
|
|
11914
|
-
|
|
11915
|
-
|
|
11916
|
-
|
|
11917
|
-
|
|
11918
|
-
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
|
-
|
|
11922
|
-
|
|
11923
|
-
|
|
11924
|
-
|
|
11954
|
+
/**
|
|
11955
|
+
* Create a regular expression from a parsed glob pattern.
|
|
11956
|
+
*
|
|
11957
|
+
* ```js
|
|
11958
|
+
* const picomatch = require('picomatch');
|
|
11959
|
+
* const state = picomatch.parse('*.js');
|
|
11960
|
+
* // picomatch.compileRe(state[, options]);
|
|
11961
|
+
*
|
|
11962
|
+
* console.log(picomatch.compileRe(state));
|
|
11963
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
11964
|
+
* ```
|
|
11965
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
11966
|
+
* @param {Object} `options`
|
|
11967
|
+
* @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.
|
|
11968
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
11969
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
11970
|
+
* @api public
|
|
11971
|
+
*/
|
|
11972
|
+
|
|
11973
|
+
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
11974
|
+
if (!input || typeof input !== 'string') {
|
|
11975
|
+
throw new TypeError('Expected a non-empty string');
|
|
11976
|
+
}
|
|
11925
11977
|
|
|
11926
|
-
|
|
11927
|
-
if (!input || typeof input !== 'string') {
|
|
11928
|
-
throw new TypeError('Expected a non-empty string');
|
|
11929
|
-
}
|
|
11978
|
+
let parsed = { negated: false, fastpaths: true };
|
|
11930
11979
|
|
|
11931
|
-
|
|
11980
|
+
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
11981
|
+
parsed.output = parse.fastpaths(input, options);
|
|
11982
|
+
}
|
|
11932
11983
|
|
|
11933
|
-
|
|
11934
|
-
|
|
11935
|
-
|
|
11984
|
+
if (!parsed.output) {
|
|
11985
|
+
parsed = parse(input, options);
|
|
11986
|
+
}
|
|
11936
11987
|
|
|
11937
|
-
|
|
11938
|
-
|
|
11939
|
-
}
|
|
11988
|
+
return picomatch.compileRe(parsed, options, returnOutput, returnState);
|
|
11989
|
+
};
|
|
11940
11990
|
|
|
11941
|
-
|
|
11942
|
-
|
|
11991
|
+
/**
|
|
11992
|
+
* Create a regular expression from the given regex source string.
|
|
11993
|
+
*
|
|
11994
|
+
* ```js
|
|
11995
|
+
* const picomatch = require('picomatch');
|
|
11996
|
+
* // picomatch.toRegex(source[, options]);
|
|
11997
|
+
*
|
|
11998
|
+
* const { output } = picomatch.parse('*.js');
|
|
11999
|
+
* console.log(picomatch.toRegex(output));
|
|
12000
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
12001
|
+
* ```
|
|
12002
|
+
* @param {String} `source` Regular expression source string.
|
|
12003
|
+
* @param {Object} `options`
|
|
12004
|
+
* @return {RegExp}
|
|
12005
|
+
* @api public
|
|
12006
|
+
*/
|
|
12007
|
+
|
|
12008
|
+
picomatch.toRegex = (source, options) => {
|
|
12009
|
+
try {
|
|
12010
|
+
const opts = options || {};
|
|
12011
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
12012
|
+
} catch (err) {
|
|
12013
|
+
if (options && options.debug === true) throw err;
|
|
12014
|
+
return /$^/;
|
|
12015
|
+
}
|
|
12016
|
+
};
|
|
11943
12017
|
|
|
11944
|
-
/**
|
|
11945
|
-
|
|
11946
|
-
|
|
11947
|
-
|
|
11948
|
-
* const picomatch = require('picomatch');
|
|
11949
|
-
* // picomatch.toRegex(source[, options]);
|
|
11950
|
-
*
|
|
11951
|
-
* const { output } = picomatch.parse('*.js');
|
|
11952
|
-
* console.log(picomatch.toRegex(output));
|
|
11953
|
-
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
11954
|
-
* ```
|
|
11955
|
-
* @param {String} `source` Regular expression source string.
|
|
11956
|
-
* @param {Object} `options`
|
|
11957
|
-
* @return {RegExp}
|
|
11958
|
-
* @api public
|
|
11959
|
-
*/
|
|
12018
|
+
/**
|
|
12019
|
+
* Picomatch constants.
|
|
12020
|
+
* @return {Object}
|
|
12021
|
+
*/
|
|
11960
12022
|
|
|
11961
|
-
picomatch
|
|
11962
|
-
try {
|
|
11963
|
-
const opts = options || {};
|
|
11964
|
-
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
11965
|
-
} catch (err) {
|
|
11966
|
-
if (options && options.debug === true) throw err;
|
|
11967
|
-
return /$^/;
|
|
11968
|
-
}
|
|
11969
|
-
};
|
|
12023
|
+
picomatch.constants = constants;
|
|
11970
12024
|
|
|
11971
|
-
/**
|
|
11972
|
-
|
|
11973
|
-
|
|
11974
|
-
*/
|
|
12025
|
+
/**
|
|
12026
|
+
* Expose "picomatch"
|
|
12027
|
+
*/
|
|
11975
12028
|
|
|
11976
|
-
|
|
12029
|
+
picomatch_1 = picomatch;
|
|
12030
|
+
return picomatch_1;
|
|
12031
|
+
}
|
|
11977
12032
|
|
|
11978
|
-
|
|
11979
|
-
|
|
11980
|
-
*/
|
|
12033
|
+
var picomatch;
|
|
12034
|
+
var hasRequiredPicomatch;
|
|
11981
12035
|
|
|
11982
|
-
|
|
12036
|
+
function requirePicomatch () {
|
|
12037
|
+
if (hasRequiredPicomatch) return picomatch;
|
|
12038
|
+
hasRequiredPicomatch = 1;
|
|
11983
12039
|
|
|
11984
|
-
|
|
12040
|
+
picomatch = /*@__PURE__*/ requirePicomatch$1();
|
|
12041
|
+
return picomatch;
|
|
12042
|
+
}
|
|
11985
12043
|
|
|
11986
|
-
|
|
12044
|
+
var picomatchExports = /*@__PURE__*/ requirePicomatch();
|
|
12045
|
+
const pm = /*@__PURE__*/getDefaultExportFromCjs(picomatchExports);
|
|
11987
12046
|
|
|
11988
12047
|
const extractors = {
|
|
11989
12048
|
ArrayPattern(names, param) {
|
|
@@ -12032,8 +12091,9 @@ function ensureArray(thing) {
|
|
|
12032
12091
|
return [thing];
|
|
12033
12092
|
}
|
|
12034
12093
|
|
|
12094
|
+
const normalizePathRegExp = new RegExp(`\\${require$$0.win32.sep}`, 'g');
|
|
12035
12095
|
const normalizePath = function normalizePath(filename) {
|
|
12036
|
-
return filename.
|
|
12096
|
+
return filename.replace(normalizePathRegExp, require$$0.posix.sep);
|
|
12037
12097
|
};
|
|
12038
12098
|
|
|
12039
12099
|
function getMatcherString(id, resolutionBase) {
|
|
@@ -12065,10 +12125,12 @@ const createFilter = function createFilter(include, exclude, options) {
|
|
|
12065
12125
|
};
|
|
12066
12126
|
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
12067
12127
|
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
12128
|
+
if (!includeMatchers.length && !excludeMatchers.length)
|
|
12129
|
+
return (id) => typeof id === 'string' && !id.includes('\0');
|
|
12068
12130
|
return function result(id) {
|
|
12069
12131
|
if (typeof id !== 'string')
|
|
12070
12132
|
return false;
|
|
12071
|
-
if (
|
|
12133
|
+
if (id.includes('\0'))
|
|
12072
12134
|
return false;
|
|
12073
12135
|
const pathId = normalizePath(id);
|
|
12074
12136
|
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
@@ -16256,8 +16318,8 @@ class Module {
|
|
|
16256
16318
|
};
|
|
16257
16319
|
}
|
|
16258
16320
|
basename() {
|
|
16259
|
-
const base = path
|
|
16260
|
-
const extension = path
|
|
16321
|
+
const base = path.basename(this.id);
|
|
16322
|
+
const extension = path.extname(this.id);
|
|
16261
16323
|
return makeLegal(extension ? base.slice(0, -extension.length) : base);
|
|
16262
16324
|
}
|
|
16263
16325
|
bindReferences() {
|
|
@@ -17611,7 +17673,7 @@ class Chunk {
|
|
|
17611
17673
|
let hashPlaceholder = null;
|
|
17612
17674
|
const { chunkFileNames, entryFileNames, file, format, preserveModules } = this.outputOptions;
|
|
17613
17675
|
if (file) {
|
|
17614
|
-
fileName = path
|
|
17676
|
+
fileName = path.basename(file);
|
|
17615
17677
|
}
|
|
17616
17678
|
else if (this.fileName === null) {
|
|
17617
17679
|
const [pattern, patternName] = preserveModules || this.facadeModule?.isUserDefinedEntryPoint
|
|
@@ -18062,12 +18124,12 @@ class Chunk {
|
|
|
18062
18124
|
return predefinedChunkName;
|
|
18063
18125
|
const { preserveModulesRoot, sanitizeFileName } = this.outputOptions;
|
|
18064
18126
|
const sanitizedId = sanitizeFileName(parseAst_js.normalize(module.id.split(QUERY_HASH_REGEX, 1)[0]));
|
|
18065
|
-
const extensionName = path
|
|
18127
|
+
const extensionName = path.extname(sanitizedId);
|
|
18066
18128
|
const idWithoutExtension = NON_ASSET_EXTENSIONS.has(extensionName)
|
|
18067
18129
|
? sanitizedId.slice(0, -extensionName.length)
|
|
18068
18130
|
: sanitizedId;
|
|
18069
18131
|
if (parseAst_js.isAbsolute(idWithoutExtension)) {
|
|
18070
|
-
if (preserveModulesRoot && path
|
|
18132
|
+
if (preserveModulesRoot && path.resolve(idWithoutExtension).startsWith(preserveModulesRoot)) {
|
|
18071
18133
|
return idWithoutExtension.slice(preserveModulesRoot.length).replace(/^[/\\]/, '');
|
|
18072
18134
|
}
|
|
18073
18135
|
else {
|
|
@@ -18079,7 +18141,7 @@ class Chunk {
|
|
|
18079
18141
|
}
|
|
18080
18142
|
}
|
|
18081
18143
|
else {
|
|
18082
|
-
return (this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + path
|
|
18144
|
+
return (this.outputOptions.virtualDirname.replace(/\/$/, '') + '/' + path.basename(idWithoutExtension));
|
|
18083
18145
|
}
|
|
18084
18146
|
}
|
|
18085
18147
|
getReexportSpecifiers() {
|
|
@@ -19062,7 +19124,7 @@ function commondir(files) {
|
|
|
19062
19124
|
if (files.length === 0)
|
|
19063
19125
|
return '/';
|
|
19064
19126
|
if (files.length === 1)
|
|
19065
|
-
return path
|
|
19127
|
+
return path.dirname(files[0]);
|
|
19066
19128
|
const commonSegments = files.slice(1).reduce((commonSegments, file) => {
|
|
19067
19129
|
const pathSegments = file.split(/\/+|\\+/);
|
|
19068
19130
|
let index;
|
|
@@ -19320,9 +19382,9 @@ function getCollapsedSourcemap(id, originalCode, originalSourcemap, sourcemapCha
|
|
|
19320
19382
|
if (originalSourcemap) {
|
|
19321
19383
|
const sources = originalSourcemap.sources;
|
|
19322
19384
|
const sourcesContent = originalSourcemap.sourcesContent || [];
|
|
19323
|
-
const directory = path
|
|
19385
|
+
const directory = path.dirname(id) || '.';
|
|
19324
19386
|
const sourceRoot = originalSourcemap.sourceRoot || '.';
|
|
19325
|
-
const baseSources = sources.map((source, index) => new Source(path
|
|
19387
|
+
const baseSources = sources.map((source, index) => new Source(path.resolve(directory, sourceRoot, source), sourcesContent[index]));
|
|
19326
19388
|
source = new Link(originalSourcemap, baseSources);
|
|
19327
19389
|
}
|
|
19328
19390
|
else {
|
|
@@ -19339,9 +19401,9 @@ function collapseSourcemaps(file, map, modules, bundleSourcemapChain, excludeCon
|
|
|
19339
19401
|
const source = bundleSourcemapChain.reduce(linkMap, link);
|
|
19340
19402
|
let { sources, sourcesContent, names, mappings } = source.traceMappings();
|
|
19341
19403
|
if (file) {
|
|
19342
|
-
const directory = path
|
|
19343
|
-
sources = sources.map((source) => path
|
|
19344
|
-
file = path
|
|
19404
|
+
const directory = path.dirname(file);
|
|
19405
|
+
sources = sources.map((source) => path.relative(directory, source));
|
|
19406
|
+
file = path.basename(file);
|
|
19345
19407
|
}
|
|
19346
19408
|
sourcesContent = (excludeContent ? null : sourcesContent);
|
|
19347
19409
|
for (const module of modules) {
|
|
@@ -19415,11 +19477,11 @@ async function transformChunk(magicString, fileName, usedModules, chunkGraph, op
|
|
|
19415
19477
|
timeStart('sourcemaps', 3);
|
|
19416
19478
|
let resultingFile;
|
|
19417
19479
|
if (file)
|
|
19418
|
-
resultingFile = path
|
|
19480
|
+
resultingFile = path.resolve(sourcemapFile || file);
|
|
19419
19481
|
else if (dir)
|
|
19420
|
-
resultingFile = path
|
|
19482
|
+
resultingFile = path.resolve(dir, fileName);
|
|
19421
19483
|
else
|
|
19422
|
-
resultingFile = path
|
|
19484
|
+
resultingFile = path.resolve(fileName);
|
|
19423
19485
|
const decodedMap = magicString.generateDecodedMap({});
|
|
19424
19486
|
map = collapseSourcemaps(resultingFile, decodedMap, usedModules, sourcemapChain, sourcemapExcludeSources, log);
|
|
19425
19487
|
for (let sourcesIndex = 0; sourcesIndex < map.sources.length; ++sourcesIndex) {
|
|
@@ -19567,7 +19629,7 @@ function emitSourceMapAndGetComment(fileName, map, pluginDriver, { sourcemap, so
|
|
|
19567
19629
|
url = map.toUrl();
|
|
19568
19630
|
}
|
|
19569
19631
|
else {
|
|
19570
|
-
const sourcemapFileName = path
|
|
19632
|
+
const sourcemapFileName = path.basename(fileName);
|
|
19571
19633
|
url = sourcemapBaseUrl
|
|
19572
19634
|
? new URL(sourcemapFileName, sourcemapBaseUrl).toString()
|
|
19573
19635
|
: sourcemapFileName;
|
|
@@ -19861,7 +19923,7 @@ async function resolveId(source, importer, preserveSymlinks, pluginDriver, modul
|
|
|
19861
19923
|
// absolute path is created. Absolute importees therefore shortcircuit the
|
|
19862
19924
|
// resolve call and require no special handing on our part.
|
|
19863
19925
|
// See https://nodejs.org/api/path.html#path_path_resolve_paths
|
|
19864
|
-
return addJsExtensionIfNecessary(importer ? path
|
|
19926
|
+
return addJsExtensionIfNecessary(importer ? path.resolve(path.dirname(importer), source) : path.resolve(source), preserveSymlinks);
|
|
19865
19927
|
}
|
|
19866
19928
|
async function addJsExtensionIfNecessary(file, preserveSymlinks) {
|
|
19867
19929
|
return ((await findFile(file, preserveSymlinks)) ??
|
|
@@ -19875,8 +19937,8 @@ async function findFile(file, preserveSymlinks) {
|
|
|
19875
19937
|
return await findFile(await promises.realpath(file), preserveSymlinks);
|
|
19876
19938
|
if ((preserveSymlinks && stats.isSymbolicLink()) || stats.isFile()) {
|
|
19877
19939
|
// check case
|
|
19878
|
-
const name = path
|
|
19879
|
-
const files = await promises.readdir(path
|
|
19940
|
+
const name = path.basename(file);
|
|
19941
|
+
const files = await promises.readdir(path.dirname(file));
|
|
19880
19942
|
if (files.includes(name))
|
|
19881
19943
|
return file;
|
|
19882
19944
|
}
|
|
@@ -20431,8 +20493,8 @@ class ModuleLoader {
|
|
|
20431
20493
|
function normalizeRelativeExternalId(source, importer) {
|
|
20432
20494
|
return parseAst_js.isRelative(source)
|
|
20433
20495
|
? importer
|
|
20434
|
-
? path
|
|
20435
|
-
: path
|
|
20496
|
+
? path.resolve(importer, '..', source)
|
|
20497
|
+
: path.resolve(source)
|
|
20436
20498
|
: source;
|
|
20437
20499
|
}
|
|
20438
20500
|
function addChunkNamesToModule(module, { fileName, name }, isUserDefined, priority) {
|
|
@@ -20805,7 +20867,7 @@ const getModuleContext = (config, context) => {
|
|
|
20805
20867
|
if (configModuleContext) {
|
|
20806
20868
|
const contextByModuleId = Object.create(null);
|
|
20807
20869
|
for (const [key, moduleContext] of Object.entries(configModuleContext)) {
|
|
20808
|
-
contextByModuleId[path
|
|
20870
|
+
contextByModuleId[path.resolve(key)] = moduleContext;
|
|
20809
20871
|
}
|
|
20810
20872
|
return id => contextByModuleId[id] ?? context;
|
|
20811
20873
|
}
|
|
@@ -20998,7 +21060,7 @@ const getPreserveModulesRoot = (config) => {
|
|
|
20998
21060
|
if (preserveModulesRoot === null || preserveModulesRoot === undefined) {
|
|
20999
21061
|
return undefined;
|
|
21000
21062
|
}
|
|
21001
|
-
return path
|
|
21063
|
+
return path.resolve(preserveModulesRoot);
|
|
21002
21064
|
};
|
|
21003
21065
|
const getAmd = (config) => {
|
|
21004
21066
|
const mergedOption = {
|
|
@@ -21295,9 +21357,9 @@ function getSortingFileType(file) {
|
|
|
21295
21357
|
return SortingFileType.SECONDARY_CHUNK;
|
|
21296
21358
|
}
|
|
21297
21359
|
async function writeOutputFile(outputFile, outputOptions) {
|
|
21298
|
-
const fileName = path
|
|
21360
|
+
const fileName = path.resolve(outputOptions.dir || path.dirname(outputOptions.file), outputFile.fileName);
|
|
21299
21361
|
// 'recursive: true' does not throw if the folder structure, or parts of it, already exist
|
|
21300
|
-
await promises.mkdir(path
|
|
21362
|
+
await promises.mkdir(path.dirname(fileName), { recursive: true });
|
|
21301
21363
|
return promises.writeFile(fileName, outputFile.type === 'asset' ? outputFile.source : outputFile.code);
|
|
21302
21364
|
}
|
|
21303
21365
|
/**
|
|
@@ -21319,6 +21381,7 @@ exports.cyan$1 = cyan;
|
|
|
21319
21381
|
exports.defineConfig = defineConfig;
|
|
21320
21382
|
exports.ensureArray = ensureArray$1;
|
|
21321
21383
|
exports.getAugmentedNamespace = getAugmentedNamespace;
|
|
21384
|
+
exports.getDefaultExportFromCjs = getDefaultExportFromCjs;
|
|
21322
21385
|
exports.getNewArray = getNewArray;
|
|
21323
21386
|
exports.getOrCreate = getOrCreate;
|
|
21324
21387
|
exports.gray = gray;
|
|
@@ -21327,7 +21390,6 @@ exports.handleError = handleError;
|
|
|
21327
21390
|
exports.isWatchEnabled = isWatchEnabled;
|
|
21328
21391
|
exports.mergeOptions = mergeOptions;
|
|
21329
21392
|
exports.normalizePluginOption = normalizePluginOption;
|
|
21330
|
-
exports.picomatch = picomatch;
|
|
21331
21393
|
exports.rollup = rollup;
|
|
21332
21394
|
exports.rollupInternal = rollupInternal;
|
|
21333
21395
|
exports.stderr = stderr;
|