format: prettify entire project
This commit is contained in:
98
node_modules/picomatch/lib/constants.js
generated
vendored
98
node_modules/picomatch/lib/constants.js
generated
vendored
@ -39,7 +39,7 @@ const POSIX_CHARS = {
|
||||
NO_DOTS_SLASH,
|
||||
QMARK_NO_DOT,
|
||||
STAR,
|
||||
START_ANCHOR
|
||||
START_ANCHOR,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ const WINDOWS_CHARS = {
|
||||
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
||||
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
||||
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
||||
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
||||
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
||||
};
|
||||
|
||||
/**
|
||||
@ -80,7 +80,7 @@ const POSIX_REGEX_SOURCE = {
|
||||
space: ' \\t\\r\\n\\v\\f',
|
||||
upper: 'A-Z',
|
||||
word: 'A-Za-z0-9_',
|
||||
xdigit: 'A-Fa-f0-9'
|
||||
xdigit: 'A-Fa-f0-9',
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
@ -99,59 +99,59 @@ module.exports = {
|
||||
REPLACEMENTS: {
|
||||
'***': '*',
|
||||
'**/**': '**',
|
||||
'**/**/**': '**'
|
||||
'**/**/**': '**',
|
||||
},
|
||||
|
||||
// Digits
|
||||
CHAR_0: 48, /* 0 */
|
||||
CHAR_9: 57, /* 9 */
|
||||
CHAR_0: 48 /* 0 */,
|
||||
CHAR_9: 57 /* 9 */,
|
||||
|
||||
// Alphabet chars.
|
||||
CHAR_UPPERCASE_A: 65, /* A */
|
||||
CHAR_LOWERCASE_A: 97, /* a */
|
||||
CHAR_UPPERCASE_Z: 90, /* Z */
|
||||
CHAR_LOWERCASE_Z: 122, /* z */
|
||||
CHAR_UPPERCASE_A: 65 /* A */,
|
||||
CHAR_LOWERCASE_A: 97 /* a */,
|
||||
CHAR_UPPERCASE_Z: 90 /* Z */,
|
||||
CHAR_LOWERCASE_Z: 122 /* z */,
|
||||
|
||||
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
||||
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
||||
CHAR_LEFT_PARENTHESES: 40 /* ( */,
|
||||
CHAR_RIGHT_PARENTHESES: 41 /* ) */,
|
||||
|
||||
CHAR_ASTERISK: 42, /* * */
|
||||
CHAR_ASTERISK: 42 /* * */,
|
||||
|
||||
// Non-alphabetic chars.
|
||||
CHAR_AMPERSAND: 38, /* & */
|
||||
CHAR_AT: 64, /* @ */
|
||||
CHAR_BACKWARD_SLASH: 92, /* \ */
|
||||
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
||||
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
||||
CHAR_COLON: 58, /* : */
|
||||
CHAR_COMMA: 44, /* , */
|
||||
CHAR_DOT: 46, /* . */
|
||||
CHAR_DOUBLE_QUOTE: 34, /* " */
|
||||
CHAR_EQUAL: 61, /* = */
|
||||
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
||||
CHAR_FORM_FEED: 12, /* \f */
|
||||
CHAR_FORWARD_SLASH: 47, /* / */
|
||||
CHAR_GRAVE_ACCENT: 96, /* ` */
|
||||
CHAR_HASH: 35, /* # */
|
||||
CHAR_HYPHEN_MINUS: 45, /* - */
|
||||
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
||||
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
||||
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
||||
CHAR_LINE_FEED: 10, /* \n */
|
||||
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
||||
CHAR_PERCENT: 37, /* % */
|
||||
CHAR_PLUS: 43, /* + */
|
||||
CHAR_QUESTION_MARK: 63, /* ? */
|
||||
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
||||
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
||||
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
||||
CHAR_SEMICOLON: 59, /* ; */
|
||||
CHAR_SINGLE_QUOTE: 39, /* ' */
|
||||
CHAR_SPACE: 32, /* */
|
||||
CHAR_TAB: 9, /* \t */
|
||||
CHAR_UNDERSCORE: 95, /* _ */
|
||||
CHAR_VERTICAL_LINE: 124, /* | */
|
||||
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
||||
CHAR_AMPERSAND: 38 /* & */,
|
||||
CHAR_AT: 64 /* @ */,
|
||||
CHAR_BACKWARD_SLASH: 92 /* \ */,
|
||||
CHAR_CARRIAGE_RETURN: 13 /* \r */,
|
||||
CHAR_CIRCUMFLEX_ACCENT: 94 /* ^ */,
|
||||
CHAR_COLON: 58 /* : */,
|
||||
CHAR_COMMA: 44 /* , */,
|
||||
CHAR_DOT: 46 /* . */,
|
||||
CHAR_DOUBLE_QUOTE: 34 /* " */,
|
||||
CHAR_EQUAL: 61 /* = */,
|
||||
CHAR_EXCLAMATION_MARK: 33 /* ! */,
|
||||
CHAR_FORM_FEED: 12 /* \f */,
|
||||
CHAR_FORWARD_SLASH: 47 /* / */,
|
||||
CHAR_GRAVE_ACCENT: 96 /* ` */,
|
||||
CHAR_HASH: 35 /* # */,
|
||||
CHAR_HYPHEN_MINUS: 45 /* - */,
|
||||
CHAR_LEFT_ANGLE_BRACKET: 60 /* < */,
|
||||
CHAR_LEFT_CURLY_BRACE: 123 /* { */,
|
||||
CHAR_LEFT_SQUARE_BRACKET: 91 /* [ */,
|
||||
CHAR_LINE_FEED: 10 /* \n */,
|
||||
CHAR_NO_BREAK_SPACE: 160 /* \u00A0 */,
|
||||
CHAR_PERCENT: 37 /* % */,
|
||||
CHAR_PLUS: 43 /* + */,
|
||||
CHAR_QUESTION_MARK: 63 /* ? */,
|
||||
CHAR_RIGHT_ANGLE_BRACKET: 62 /* > */,
|
||||
CHAR_RIGHT_CURLY_BRACE: 125 /* } */,
|
||||
CHAR_RIGHT_SQUARE_BRACKET: 93 /* ] */,
|
||||
CHAR_SEMICOLON: 59 /* ; */,
|
||||
CHAR_SINGLE_QUOTE: 39 /* ' */,
|
||||
CHAR_SPACE: 32 /* */,
|
||||
CHAR_TAB: 9 /* \t */,
|
||||
CHAR_UNDERSCORE: 95 /* _ */,
|
||||
CHAR_VERTICAL_LINE: 124 /* | */,
|
||||
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279 /* \uFEFF */,
|
||||
|
||||
SEP: path.sep,
|
||||
|
||||
@ -165,7 +165,7 @@ module.exports = {
|
||||
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
||||
'+': { type: 'plus', open: '(?:', close: ')+' },
|
||||
'*': { type: 'star', open: '(?:', close: ')*' },
|
||||
'@': { type: 'at', open: '(?:', close: ')' }
|
||||
'@': { type: 'at', open: '(?:', close: ')' },
|
||||
};
|
||||
},
|
||||
|
||||
@ -175,5 +175,5 @@ module.exports = {
|
||||
|
||||
globChars(win32) {
|
||||
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
242
node_modules/picomatch/lib/parse.js
generated
vendored
242
node_modules/picomatch/lib/parse.js
generated
vendored
@ -12,7 +12,7 @@ const {
|
||||
POSIX_REGEX_SOURCE,
|
||||
REGEX_NON_SPECIAL_CHARS,
|
||||
REGEX_SPECIAL_CHARS_BACKREF,
|
||||
REPLACEMENTS
|
||||
REPLACEMENTS,
|
||||
} = constants;
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ const expandRange = (args, options) => {
|
||||
/* eslint-disable-next-line no-new */
|
||||
new RegExp(value);
|
||||
} catch (ex) {
|
||||
return args.map(v => utils.escapeRegex(v)).join('..');
|
||||
return args.map((v) => utils.escapeRegex(v)).join('..');
|
||||
}
|
||||
|
||||
return value;
|
||||
@ -60,11 +60,16 @@ const parse = (input, options) => {
|
||||
input = REPLACEMENTS[input] || input;
|
||||
|
||||
const opts = { ...options };
|
||||
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
const max =
|
||||
typeof opts.maxLength === 'number' ?
|
||||
Math.min(MAX_LENGTH, opts.maxLength)
|
||||
: MAX_LENGTH;
|
||||
|
||||
let len = input.length;
|
||||
if (len > max) {
|
||||
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
||||
throw new SyntaxError(
|
||||
`Input length: ${len}, exceeds maximum allowed length: ${max}`
|
||||
);
|
||||
}
|
||||
|
||||
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
||||
@ -89,10 +94,10 @@ const parse = (input, options) => {
|
||||
QMARK,
|
||||
QMARK_NO_DOT,
|
||||
STAR,
|
||||
START_ANCHOR
|
||||
START_ANCHOR,
|
||||
} = PLATFORM_CHARS;
|
||||
|
||||
const globstar = opts => {
|
||||
const globstar = (opts) => {
|
||||
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
||||
};
|
||||
|
||||
@ -124,7 +129,7 @@ const parse = (input, options) => {
|
||||
parens: 0,
|
||||
quotes: 0,
|
||||
globstar: false,
|
||||
tokens
|
||||
tokens,
|
||||
};
|
||||
|
||||
input = utils.removePrefix(input, state);
|
||||
@ -141,15 +146,15 @@ const parse = (input, options) => {
|
||||
*/
|
||||
|
||||
const eos = () => state.index === len - 1;
|
||||
const peek = state.peek = (n = 1) => input[state.index + n];
|
||||
const advance = state.advance = () => input[++state.index] || '';
|
||||
const peek = (state.peek = (n = 1) => input[state.index + n]);
|
||||
const advance = (state.advance = () => input[++state.index] || '');
|
||||
const remaining = () => input.slice(state.index + 1);
|
||||
const consume = (value = '', num = 0) => {
|
||||
state.consumed += value;
|
||||
state.index += num;
|
||||
};
|
||||
|
||||
const append = token => {
|
||||
const append = (token) => {
|
||||
state.output += token.output != null ? token.output : token.value;
|
||||
consume(token.value);
|
||||
};
|
||||
@ -172,12 +177,12 @@ const parse = (input, options) => {
|
||||
return true;
|
||||
};
|
||||
|
||||
const increment = type => {
|
||||
const increment = (type) => {
|
||||
state[type]++;
|
||||
stack.push(type);
|
||||
};
|
||||
|
||||
const decrement = type => {
|
||||
const decrement = (type) => {
|
||||
state[type]--;
|
||||
stack.pop();
|
||||
};
|
||||
@ -190,12 +195,20 @@ const parse = (input, options) => {
|
||||
* lookbehinds.
|
||||
*/
|
||||
|
||||
const push = tok => {
|
||||
const push = (tok) => {
|
||||
if (prev.type === 'globstar') {
|
||||
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
||||
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
||||
const isBrace =
|
||||
state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
||||
const isExtglob =
|
||||
tok.extglob === true ||
|
||||
(extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
||||
|
||||
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
||||
if (
|
||||
tok.type !== 'slash' &&
|
||||
tok.type !== 'paren' &&
|
||||
!isBrace &&
|
||||
!isExtglob
|
||||
) {
|
||||
state.output = state.output.slice(0, -prev.output.length);
|
||||
prev.type = 'star';
|
||||
prev.value = '*';
|
||||
@ -234,7 +247,7 @@ const parse = (input, options) => {
|
||||
extglobs.push(token);
|
||||
};
|
||||
|
||||
const extglobClose = token => {
|
||||
const extglobClose = (token) => {
|
||||
let output = token.close + (opts.capture ? ')' : '');
|
||||
let rest;
|
||||
|
||||
@ -249,7 +262,11 @@ const parse = (input, options) => {
|
||||
output = token.close = `)$))${extglobStar}`;
|
||||
}
|
||||
|
||||
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
||||
if (
|
||||
token.inner.includes('*') &&
|
||||
(rest = remaining()) &&
|
||||
/^\.[^\\/.]+$/.test(rest)
|
||||
) {
|
||||
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
||||
// In this case, we need to parse the string and use it in the output of the original pattern.
|
||||
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
||||
@ -276,41 +293,48 @@ const parse = (input, options) => {
|
||||
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
||||
let backslashes = false;
|
||||
|
||||
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
||||
if (first === '\\') {
|
||||
backslashes = true;
|
||||
return m;
|
||||
}
|
||||
|
||||
if (first === '?') {
|
||||
if (esc) {
|
||||
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
||||
let output = input.replace(
|
||||
REGEX_SPECIAL_CHARS_BACKREF,
|
||||
(m, esc, chars, first, rest, index) => {
|
||||
if (first === '\\') {
|
||||
backslashes = true;
|
||||
return m;
|
||||
}
|
||||
if (index === 0) {
|
||||
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
||||
}
|
||||
return QMARK.repeat(chars.length);
|
||||
}
|
||||
|
||||
if (first === '.') {
|
||||
return DOT_LITERAL.repeat(chars.length);
|
||||
}
|
||||
|
||||
if (first === '*') {
|
||||
if (esc) {
|
||||
return esc + first + (rest ? star : '');
|
||||
if (first === '?') {
|
||||
if (esc) {
|
||||
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
||||
}
|
||||
if (index === 0) {
|
||||
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
||||
}
|
||||
return QMARK.repeat(chars.length);
|
||||
}
|
||||
return star;
|
||||
|
||||
if (first === '.') {
|
||||
return DOT_LITERAL.repeat(chars.length);
|
||||
}
|
||||
|
||||
if (first === '*') {
|
||||
if (esc) {
|
||||
return esc + first + (rest ? star : '');
|
||||
}
|
||||
return star;
|
||||
}
|
||||
return esc ? m : `\\${m}`;
|
||||
}
|
||||
return esc ? m : `\\${m}`;
|
||||
});
|
||||
);
|
||||
|
||||
if (backslashes === true) {
|
||||
if (opts.unescape === true) {
|
||||
output = output.replace(/\\/g, '');
|
||||
} else {
|
||||
output = output.replace(/\\+/g, m => {
|
||||
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
||||
output = output.replace(/\\+/g, (m) => {
|
||||
return (
|
||||
m.length % 2 === 0 ? '\\\\'
|
||||
: m ? '\\'
|
||||
: ''
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -385,7 +409,10 @@ const parse = (input, options) => {
|
||||
* until we reach the closing bracket.
|
||||
*/
|
||||
|
||||
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
||||
if (
|
||||
state.brackets > 0 &&
|
||||
(value !== ']' || prev.value === '[' || prev.value === '[^')
|
||||
) {
|
||||
if (opts.posix !== false && value === ':') {
|
||||
const inner = prev.value.slice(1);
|
||||
if (inner.includes('[')) {
|
||||
@ -410,7 +437,10 @@ const parse = (input, options) => {
|
||||
}
|
||||
}
|
||||
|
||||
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
||||
if (
|
||||
(value === '[' && peek() !== ':') ||
|
||||
(value === '-' && peek() === ']')
|
||||
) {
|
||||
value = `\\${value}`;
|
||||
}
|
||||
|
||||
@ -497,7 +527,10 @@ const parse = (input, options) => {
|
||||
}
|
||||
|
||||
if (value === ']') {
|
||||
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
||||
if (
|
||||
opts.nobracket === true ||
|
||||
(prev && prev.type === 'bracket' && prev.value.length === 1)
|
||||
) {
|
||||
push({ type: 'text', value, output: `\\${value}` });
|
||||
continue;
|
||||
}
|
||||
@ -514,7 +547,11 @@ const parse = (input, options) => {
|
||||
decrement('brackets');
|
||||
|
||||
const prevValue = prev.value.slice(1);
|
||||
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
||||
if (
|
||||
prev.posix !== true &&
|
||||
prevValue[0] === '^' &&
|
||||
!prevValue.includes('/')
|
||||
) {
|
||||
value = `/${value}`;
|
||||
}
|
||||
|
||||
@ -556,7 +593,7 @@ const parse = (input, options) => {
|
||||
value,
|
||||
output: '(',
|
||||
outputIndex: state.output.length,
|
||||
tokensIndex: state.tokens.length
|
||||
tokensIndex: state.tokens.length,
|
||||
};
|
||||
|
||||
braces.push(open);
|
||||
@ -599,7 +636,7 @@ const parse = (input, options) => {
|
||||
value = output = '\\}';
|
||||
state.output = out;
|
||||
for (const t of toks) {
|
||||
state.output += (t.output || t.value);
|
||||
state.output += t.output || t.value;
|
||||
}
|
||||
}
|
||||
|
||||
@ -675,7 +712,11 @@ const parse = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
||||
if (
|
||||
state.braces + state.parens === 0 &&
|
||||
prev.type !== 'bos' &&
|
||||
prev.type !== 'slash'
|
||||
) {
|
||||
push({ type: 'text', value, output: DOT_LITERAL });
|
||||
continue;
|
||||
}
|
||||
@ -690,7 +731,12 @@ const parse = (input, options) => {
|
||||
|
||||
if (value === '?') {
|
||||
const isGroup = prev && prev.value === '(';
|
||||
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
||||
if (
|
||||
!isGroup &&
|
||||
opts.noextglob !== true &&
|
||||
peek() === '(' &&
|
||||
peek(2) !== '?'
|
||||
) {
|
||||
extglobOpen('qmark', value);
|
||||
continue;
|
||||
}
|
||||
@ -700,10 +746,15 @@ const parse = (input, options) => {
|
||||
let output = value;
|
||||
|
||||
if (next === '<' && !utils.supportsLookbehinds()) {
|
||||
throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
||||
throw new Error(
|
||||
'Node.js v10 or higher is required for regex lookbehinds'
|
||||
);
|
||||
}
|
||||
|
||||
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
||||
if (
|
||||
(prev.value === '(' && !/[!=<:]/.test(next)) ||
|
||||
(next === '<' && !/<([!=]|\w+>)/.test(remaining()))
|
||||
) {
|
||||
output = `\\${value}`;
|
||||
}
|
||||
|
||||
@ -753,7 +804,13 @@ const parse = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
||||
if (
|
||||
(prev &&
|
||||
(prev.type === 'bracket' ||
|
||||
prev.type === 'paren' ||
|
||||
prev.type === 'brace')) ||
|
||||
state.parens > 0
|
||||
) {
|
||||
push({ type: 'plus', value });
|
||||
continue;
|
||||
}
|
||||
@ -825,15 +882,18 @@ const parse = (input, options) => {
|
||||
const prior = prev.prev;
|
||||
const before = prior.prev;
|
||||
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
||||
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
||||
const afterStar =
|
||||
before && (before.type === 'star' || before.type === 'globstar');
|
||||
|
||||
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
||||
push({ type: 'star', value, output: '' });
|
||||
continue;
|
||||
}
|
||||
|
||||
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
||||
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
||||
const isBrace =
|
||||
state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
||||
const isExtglob =
|
||||
extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
||||
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
||||
push({ type: 'star', value, output: '' });
|
||||
continue;
|
||||
@ -859,8 +919,16 @@ const parse = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
||||
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
||||
if (
|
||||
prior.type === 'slash' &&
|
||||
prior.prev.type !== 'bos' &&
|
||||
!afterStar &&
|
||||
eos()
|
||||
) {
|
||||
state.output = state.output.slice(
|
||||
0,
|
||||
-(prior.output + prev.output).length
|
||||
);
|
||||
prior.output = `(?:${prior.output}`;
|
||||
|
||||
prev.type = 'globstar';
|
||||
@ -872,10 +940,17 @@ const parse = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
||||
if (
|
||||
prior.type === 'slash' &&
|
||||
prior.prev.type !== 'bos' &&
|
||||
rest[0] === '/'
|
||||
) {
|
||||
const end = rest[1] !== void 0 ? '|$' : '';
|
||||
|
||||
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
||||
state.output = state.output.slice(
|
||||
0,
|
||||
-(prior.output + prev.output).length
|
||||
);
|
||||
prior.output = `(?:${prior.output}`;
|
||||
|
||||
prev.type = 'globstar';
|
||||
@ -928,21 +1003,27 @@ const parse = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
||||
if (
|
||||
prev &&
|
||||
(prev.type === 'bracket' || prev.type === 'paren') &&
|
||||
opts.regex === true
|
||||
) {
|
||||
token.output = value;
|
||||
push(token);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
||||
if (
|
||||
state.index === state.start ||
|
||||
prev.type === 'slash' ||
|
||||
prev.type === 'dot'
|
||||
) {
|
||||
if (prev.type === 'dot') {
|
||||
state.output += NO_DOT_SLASH;
|
||||
prev.output += NO_DOT_SLASH;
|
||||
|
||||
} else if (opts.dot === true) {
|
||||
state.output += NO_DOTS_SLASH;
|
||||
prev.output += NO_DOTS_SLASH;
|
||||
|
||||
} else {
|
||||
state.output += nodot;
|
||||
prev.output += nodot;
|
||||
@ -958,24 +1039,30 @@ const parse = (input, options) => {
|
||||
}
|
||||
|
||||
while (state.brackets > 0) {
|
||||
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
||||
if (opts.strictBrackets === true)
|
||||
throw new SyntaxError(syntaxError('closing', ']'));
|
||||
state.output = utils.escapeLast(state.output, '[');
|
||||
decrement('brackets');
|
||||
}
|
||||
|
||||
while (state.parens > 0) {
|
||||
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
||||
if (opts.strictBrackets === true)
|
||||
throw new SyntaxError(syntaxError('closing', ')'));
|
||||
state.output = utils.escapeLast(state.output, '(');
|
||||
decrement('parens');
|
||||
}
|
||||
|
||||
while (state.braces > 0) {
|
||||
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
||||
if (opts.strictBrackets === true)
|
||||
throw new SyntaxError(syntaxError('closing', '}'));
|
||||
state.output = utils.escapeLast(state.output, '{');
|
||||
decrement('braces');
|
||||
}
|
||||
|
||||
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
||||
if (
|
||||
opts.strictSlashes !== true &&
|
||||
(prev.type === 'star' || prev.type === 'bracket')
|
||||
) {
|
||||
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
||||
}
|
||||
|
||||
@ -1003,10 +1090,15 @@ const parse = (input, options) => {
|
||||
|
||||
parse.fastpaths = (input, options) => {
|
||||
const opts = { ...options };
|
||||
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
||||
const max =
|
||||
typeof opts.maxLength === 'number' ?
|
||||
Math.min(MAX_LENGTH, opts.maxLength)
|
||||
: MAX_LENGTH;
|
||||
const len = input.length;
|
||||
if (len > max) {
|
||||
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
||||
throw new SyntaxError(
|
||||
`Input length: ${len}, exceeds maximum allowed length: ${max}`
|
||||
);
|
||||
}
|
||||
|
||||
input = REPLACEMENTS[input] || input;
|
||||
@ -1022,7 +1114,7 @@ parse.fastpaths = (input, options) => {
|
||||
NO_DOTS,
|
||||
NO_DOTS_SLASH,
|
||||
STAR,
|
||||
START_ANCHOR
|
||||
START_ANCHOR,
|
||||
} = constants.globChars(win32);
|
||||
|
||||
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
||||
@ -1035,12 +1127,12 @@ parse.fastpaths = (input, options) => {
|
||||
star = `(${star})`;
|
||||
}
|
||||
|
||||
const globstar = opts => {
|
||||
const globstar = (opts) => {
|
||||
if (opts.noglobstar === true) return star;
|
||||
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
||||
};
|
||||
|
||||
const create = str => {
|
||||
const create = (str) => {
|
||||
switch (str) {
|
||||
case '*':
|
||||
return `${nodot}${ONE_CHAR}${star}`;
|
||||
|
52
node_modules/picomatch/lib/picomatch.js
generated
vendored
52
node_modules/picomatch/lib/picomatch.js
generated
vendored
@ -5,7 +5,7 @@ const scan = require('./scan');
|
||||
const parse = require('./parse');
|
||||
const utils = require('./utils');
|
||||
const constants = require('./constants');
|
||||
const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
||||
const isObject = (val) => val && typeof val === 'object' && !Array.isArray(val);
|
||||
|
||||
/**
|
||||
* Creates a matcher function from one or more glob patterns. The
|
||||
@ -31,8 +31,8 @@ const isObject = val => val && typeof val === 'object' && !Array.isArray(val);
|
||||
|
||||
const picomatch = (glob, options, returnState = false) => {
|
||||
if (Array.isArray(glob)) {
|
||||
const fns = glob.map(input => picomatch(input, options, returnState));
|
||||
const arrayMatcher = str => {
|
||||
const fns = glob.map((input) => picomatch(input, options, returnState));
|
||||
const arrayMatcher = (str) => {
|
||||
for (const isMatch of fns) {
|
||||
const state = isMatch(str);
|
||||
if (state) return state;
|
||||
@ -50,8 +50,9 @@ const picomatch = (glob, options, returnState = false) => {
|
||||
|
||||
const opts = options || {};
|
||||
const posix = utils.isWindows(options);
|
||||
const regex = isState
|
||||
? picomatch.compileRe(glob, options)
|
||||
const regex =
|
||||
isState ?
|
||||
picomatch.compileRe(glob, options)
|
||||
: picomatch.makeRe(glob, options, false, true);
|
||||
|
||||
const state = regex.state;
|
||||
@ -59,12 +60,20 @@ const picomatch = (glob, options, returnState = false) => {
|
||||
|
||||
let isIgnored = () => false;
|
||||
if (opts.ignore) {
|
||||
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
||||
const ignoreOpts = {
|
||||
...options,
|
||||
ignore: null,
|
||||
onMatch: null,
|
||||
onResult: null,
|
||||
};
|
||||
isIgnored = picomatch(opts.ignore, ignoreOpts, returnState);
|
||||
}
|
||||
|
||||
const matcher = (input, returnObject = false) => {
|
||||
const { isMatch, match, output } = picomatch.test(input, regex, options, { glob, posix });
|
||||
const { isMatch, match, output } = picomatch.test(input, regex, options, {
|
||||
glob,
|
||||
posix,
|
||||
});
|
||||
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
||||
|
||||
if (typeof opts.onResult === 'function') {
|
||||
@ -126,7 +135,7 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
||||
const opts = options || {};
|
||||
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
||||
let match = input === glob;
|
||||
let output = (match && format) ? format(input) : input;
|
||||
let output = match && format ? format(input) : input;
|
||||
|
||||
if (match === false) {
|
||||
output = format ? format(input) : input;
|
||||
@ -158,7 +167,12 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
||||
picomatch.matchBase = (
|
||||
input,
|
||||
glob,
|
||||
options,
|
||||
posix = utils.isWindows(options)
|
||||
) => {
|
||||
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
|
||||
return regex.test(path.basename(input));
|
||||
};
|
||||
@ -180,7 +194,8 @@ picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) =
|
||||
* @api public
|
||||
*/
|
||||
|
||||
picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str);
|
||||
picomatch.isMatch = (str, patterns, options) =>
|
||||
picomatch(patterns, options)(str);
|
||||
|
||||
/**
|
||||
* Parse a glob pattern to create the source string for a regular
|
||||
@ -197,7 +212,8 @@ picomatch.isMatch = (str, patterns, options) => picomatch(patterns, options)(str
|
||||
*/
|
||||
|
||||
picomatch.parse = (pattern, options) => {
|
||||
if (Array.isArray(pattern)) return pattern.map(p => picomatch.parse(p, options));
|
||||
if (Array.isArray(pattern))
|
||||
return pattern.map((p) => picomatch.parse(p, options));
|
||||
return parse(pattern, { ...options, fastpaths: false });
|
||||
};
|
||||
|
||||
@ -242,7 +258,12 @@ picomatch.scan = (input, options) => scan(input, options);
|
||||
* @api public
|
||||
*/
|
||||
|
||||
picomatch.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
||||
picomatch.compileRe = (
|
||||
state,
|
||||
options,
|
||||
returnOutput = false,
|
||||
returnState = false
|
||||
) => {
|
||||
if (returnOutput === true) {
|
||||
return state.output;
|
||||
}
|
||||
@ -283,7 +304,12 @@ picomatch.compileRe = (state, options, returnOutput = false, returnState = false
|
||||
* @api public
|
||||
*/
|
||||
|
||||
picomatch.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
||||
picomatch.makeRe = (
|
||||
input,
|
||||
options = {},
|
||||
returnOutput = false,
|
||||
returnState = false
|
||||
) => {
|
||||
if (!input || typeof input !== 'string') {
|
||||
throw new TypeError('Expected a non-empty string');
|
||||
}
|
||||
|
61
node_modules/picomatch/lib/scan.js
generated
vendored
61
node_modules/picomatch/lib/scan.js
generated
vendored
@ -2,28 +2,28 @@
|
||||
|
||||
const utils = require('./utils');
|
||||
const {
|
||||
CHAR_ASTERISK, /* * */
|
||||
CHAR_AT, /* @ */
|
||||
CHAR_BACKWARD_SLASH, /* \ */
|
||||
CHAR_COMMA, /* , */
|
||||
CHAR_DOT, /* . */
|
||||
CHAR_EXCLAMATION_MARK, /* ! */
|
||||
CHAR_FORWARD_SLASH, /* / */
|
||||
CHAR_LEFT_CURLY_BRACE, /* { */
|
||||
CHAR_LEFT_PARENTHESES, /* ( */
|
||||
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
||||
CHAR_PLUS, /* + */
|
||||
CHAR_QUESTION_MARK, /* ? */
|
||||
CHAR_RIGHT_CURLY_BRACE, /* } */
|
||||
CHAR_RIGHT_PARENTHESES, /* ) */
|
||||
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
||||
CHAR_ASTERISK /* * */,
|
||||
CHAR_AT /* @ */,
|
||||
CHAR_BACKWARD_SLASH /* \ */,
|
||||
CHAR_COMMA /* , */,
|
||||
CHAR_DOT /* . */,
|
||||
CHAR_EXCLAMATION_MARK /* ! */,
|
||||
CHAR_FORWARD_SLASH /* / */,
|
||||
CHAR_LEFT_CURLY_BRACE /* { */,
|
||||
CHAR_LEFT_PARENTHESES /* ( */,
|
||||
CHAR_LEFT_SQUARE_BRACKET /* [ */,
|
||||
CHAR_PLUS /* + */,
|
||||
CHAR_QUESTION_MARK /* ? */,
|
||||
CHAR_RIGHT_CURLY_BRACE /* } */,
|
||||
CHAR_RIGHT_PARENTHESES /* ) */,
|
||||
CHAR_RIGHT_SQUARE_BRACKET /* ] */,
|
||||
} = require('./constants');
|
||||
|
||||
const isPathSeparator = code => {
|
||||
const isPathSeparator = (code) => {
|
||||
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
||||
};
|
||||
|
||||
const depth = token => {
|
||||
const depth = (token) => {
|
||||
if (token.isPrefix !== true) {
|
||||
token.depth = token.isGlobstar ? Infinity : 1;
|
||||
}
|
||||
@ -110,7 +110,11 @@ const scan = (input, options) => {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
||||
if (
|
||||
braceEscaped !== true &&
|
||||
code === CHAR_DOT &&
|
||||
(code = advance()) === CHAR_DOT
|
||||
) {
|
||||
isBrace = token.isBrace = true;
|
||||
isGlob = token.isGlob = true;
|
||||
finished = true;
|
||||
@ -159,7 +163,7 @@ const scan = (input, options) => {
|
||||
token = { value: '', depth: 0, isGlob: false };
|
||||
|
||||
if (finished === true) continue;
|
||||
if (prev === CHAR_DOT && index === (start + 1)) {
|
||||
if (prev === CHAR_DOT && index === start + 1) {
|
||||
start += 2;
|
||||
continue;
|
||||
}
|
||||
@ -169,11 +173,12 @@ const scan = (input, options) => {
|
||||
}
|
||||
|
||||
if (opts.noext !== true) {
|
||||
const isExtglobChar = code === CHAR_PLUS
|
||||
|| code === CHAR_AT
|
||||
|| code === CHAR_ASTERISK
|
||||
|| code === CHAR_QUESTION_MARK
|
||||
|| code === CHAR_EXCLAMATION_MARK;
|
||||
const isExtglobChar =
|
||||
code === CHAR_PLUS ||
|
||||
code === CHAR_AT ||
|
||||
code === CHAR_ASTERISK ||
|
||||
code === CHAR_QUESTION_MARK ||
|
||||
code === CHAR_EXCLAMATION_MARK;
|
||||
|
||||
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
||||
isGlob = token.isGlob = true;
|
||||
@ -247,7 +252,11 @@ const scan = (input, options) => {
|
||||
break;
|
||||
}
|
||||
|
||||
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
||||
if (
|
||||
opts.nonegate !== true &&
|
||||
code === CHAR_EXCLAMATION_MARK &&
|
||||
index === start
|
||||
) {
|
||||
negated = token.negated = true;
|
||||
start++;
|
||||
continue;
|
||||
@ -336,7 +345,7 @@ const scan = (input, options) => {
|
||||
isExtglob,
|
||||
isGlobstar,
|
||||
negated,
|
||||
negatedExtglob
|
||||
negatedExtglob,
|
||||
};
|
||||
|
||||
if (opts.tokens === true) {
|
||||
|
21
node_modules/picomatch/lib/utils.js
generated
vendored
21
node_modules/picomatch/lib/utils.js
generated
vendored
@ -6,30 +6,31 @@ const {
|
||||
REGEX_BACKSLASH,
|
||||
REGEX_REMOVE_BACKSLASH,
|
||||
REGEX_SPECIAL_CHARS,
|
||||
REGEX_SPECIAL_CHARS_GLOBAL
|
||||
REGEX_SPECIAL_CHARS_GLOBAL,
|
||||
} = require('./constants');
|
||||
|
||||
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
||||
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
||||
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
||||
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
||||
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
||||
exports.isObject = (val) =>
|
||||
val !== null && typeof val === 'object' && !Array.isArray(val);
|
||||
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
||||
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
||||
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
||||
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, '/');
|
||||
|
||||
exports.removeBackslashes = str => {
|
||||
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
||||
exports.removeBackslashes = (str) => {
|
||||
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
||||
return match === '\\' ? '' : match;
|
||||
});
|
||||
};
|
||||
|
||||
exports.supportsLookbehinds = () => {
|
||||
const segs = process.version.slice(1).split('.').map(Number);
|
||||
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
|
||||
if ((segs.length === 3 && segs[0] >= 9) || (segs[0] === 8 && segs[1] >= 10)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
exports.isWindows = options => {
|
||||
exports.isWindows = (options) => {
|
||||
if (options && typeof options.windows === 'boolean') {
|
||||
return options.windows;
|
||||
}
|
||||
|
Reference in New Issue
Block a user