This commit is contained in:
2025-04-17 19:16:42 +02:00
parent 94a90edabd
commit ab2db755ef
88 changed files with 8427 additions and 10994 deletions

View File

@@ -1,6 +1,5 @@
'use strict';
const path = require('path');
const WIN_SLASH = '\\\\/';
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
@@ -23,6 +22,7 @@ const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
const STAR = `${QMARK}*?`;
const SEP = '/';
const POSIX_CHARS = {
DOT_LITERAL,
@@ -39,7 +39,8 @@ const POSIX_CHARS = {
NO_DOTS_SLASH,
QMARK_NO_DOT,
STAR,
START_ANCHOR
START_ANCHOR,
SEP
};
/**
@@ -59,7 +60,8 @@ 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}]|$)`,
SEP: '\\'
};
/**
@@ -153,8 +155,6 @@ module.exports = {
CHAR_VERTICAL_LINE: 124, /* | */
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
SEP: path.sep,
/**
* Create EXTGLOB_CHARS
*/

12
node_modules/picomatch/lib/parse.js generated vendored
View File

@@ -71,10 +71,9 @@ const parse = (input, options) => {
const tokens = [bos];
const capture = opts.capture ? '' : '?:';
const win32 = utils.isWindows(options);
// create constants based on platform, for windows or posix
const PLATFORM_CHARS = constants.globChars(win32);
const PLATFORM_CHARS = constants.globChars(opts.windows);
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
const {
@@ -210,8 +209,8 @@ const parse = (input, options) => {
if (tok.value || tok.output) append(tok);
if (prev && prev.type === 'text' && tok.type === 'text') {
prev.output = (prev.output || prev.value) + tok.value;
prev.value += tok.value;
prev.output = (prev.output || '') + tok.value;
return;
}
@@ -699,10 +698,6 @@ const parse = (input, options) => {
const next = peek();
let output = value;
if (next === '<' && !utils.supportsLookbehinds()) {
throw new Error('Node.js v10 or higher is required for regex lookbehinds');
}
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
output = `\\${value}`;
}
@@ -1010,7 +1005,6 @@ parse.fastpaths = (input, options) => {
}
input = REPLACEMENTS[input] || input;
const win32 = utils.isWindows(options);
// create constants based on platform, for windows or posix
const {
@@ -1023,7 +1017,7 @@ parse.fastpaths = (input, options) => {
NO_DOTS_SLASH,
STAR,
START_ANCHOR
} = constants.globChars(win32);
} = constants.globChars(opts.windows);
const nodot = opts.dot ? NO_DOTS : NO_DOT;
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;

View File

@@ -1,6 +1,5 @@
'use strict';
const path = require('path');
const scan = require('./scan');
const parse = require('./parse');
const utils = require('./utils');
@@ -49,7 +48,7 @@ const picomatch = (glob, options, returnState = false) => {
}
const opts = options || {};
const posix = utils.isWindows(options);
const posix = opts.windows;
const regex = isState
? picomatch.compileRe(glob, options)
: picomatch.makeRe(glob, options, false, true);
@@ -158,9 +157,9 @@ picomatch.test = (input, regex, options, { glob, posix } = {}) => {
* @api public
*/
picomatch.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
picomatch.matchBase = (input, glob, options) => {
const regex = glob instanceof RegExp ? glob : picomatch.makeRe(glob, options);
return regex.test(path.basename(input));
return regex.test(utils.basename(input));
};
/**

42
node_modules/picomatch/lib/utils.js generated vendored
View File

@@ -1,7 +1,6 @@
/*global navigator*/
'use strict';
const path = require('path');
const win32 = process.platform === 'win32';
const {
REGEX_BACKSLASH,
REGEX_REMOVE_BACKSLASH,
@@ -15,27 +14,25 @@ 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.isWindows = () => {
if (typeof navigator !== 'undefined' && navigator.platform) {
const platform = navigator.platform.toLowerCase();
return platform === 'win32' || platform === 'windows';
}
if (typeof process !== 'undefined' && process.platform) {
return process.platform === 'win32';
}
return false;
};
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)) {
return true;
}
return false;
};
exports.isWindows = options => {
if (options && typeof options.windows === 'boolean') {
return options.windows;
}
return win32 === true || path.sep === '\\';
};
exports.escapeLast = (input, char, lastIdx) => {
const idx = input.lastIndexOf(char, lastIdx);
if (idx === -1) return input;
@@ -62,3 +59,14 @@ exports.wrapOutput = (input, state = {}, options = {}) => {
}
return output;
};
exports.basename = (path, { windows } = {}) => {
const segs = path.split(windows ? /[\\/]/ : '/');
const last = segs[segs.length - 1];
if (last === '') {
return segs[segs.length - 2];
}
return last;
};