This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+26 -20
View File
@@ -16,7 +16,7 @@ const minimatch = (p, pattern, options = {}) => {
};
exports.minimatch = minimatch;
// Optimized checking for the most common glob patterns.
const starDotExtRE = /^\*+([^+@!?\*\[\(]*)$/;
const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
const starDotExtTestNocase = (ext) => {
@@ -35,7 +35,7 @@ const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
const starRE = /^\*+$/;
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
const qmarksRE = /^\?+([^+@!?\*\[\(]*)?$/;
const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
const qmarksTestNocase = ([$0, ext = '']) => {
const noext = qmarksTestNoExt([$0]);
if (!ext)
@@ -267,6 +267,7 @@ class Minimatch {
// step 2: expand braces
this.globSet = [...new Set(this.braceExpand())];
if (options.debug) {
//oxlint-disable-next-line no-console
this.debug = (...args) => console.error(...args);
}
this.debug(this.pattern, this.globSet);
@@ -329,10 +330,10 @@ class Minimatch {
preprocess(globParts) {
// if we're not in globstar mode, then turn ** into *
if (this.options.noglobstar) {
for (let i = 0; i < globParts.length; i++) {
for (let j = 0; j < globParts[i].length; j++) {
if (globParts[i][j] === '**') {
globParts[i][j] = '*';
for (const partset of globParts) {
for (let j = 0; j < partset.length; j++) {
if (partset[j] === '**') {
partset[j] = '*';
}
}
}
@@ -420,7 +421,11 @@ class Minimatch {
let dd = 0;
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
const p = parts[dd - 1];
if (p && p !== '.' && p !== '..' && p !== '**') {
if (p &&
p !== '.' &&
p !== '..' &&
p !== '**' &&
!(this.isWindows && /^[a-z]:$/i.test(p))) {
didSomething = true;
parts.splice(dd - 1, 2);
dd -= 2;
@@ -669,15 +674,17 @@ class Minimatch {
// split the pattern up into globstar-delimited sections
// the tail has to be at the end, and the others just have
// to be found in order from the head.
const [head, body, tail] = partial ? [
pattern.slice(patternIndex, firstgs),
pattern.slice(firstgs + 1),
[],
] : [
pattern.slice(patternIndex, firstgs),
pattern.slice(firstgs + 1, lastgs),
pattern.slice(lastgs + 1),
];
const [head, body, tail] = partial ?
[
pattern.slice(patternIndex, firstgs),
pattern.slice(firstgs + 1),
[],
]
: [
pattern.slice(patternIndex, firstgs),
pattern.slice(firstgs + 1, lastgs),
pattern.slice(lastgs + 1),
];
// check the head, from the current file/pattern index.
if (head.length) {
const fileHead = file.slice(fileIndex, fileIndex + head.length);
@@ -1023,7 +1030,7 @@ class Minimatch {
this.regexp = new RegExp(re, [...flags].join(''));
/* c8 ignore start */
}
catch (ex) {
catch {
// should be impossible
this.regexp = false;
}
@@ -1038,7 +1045,7 @@ class Minimatch {
if (this.preserveMultipleSlashes) {
return p.split('/');
}
else if (this.isWindows && /^\/\/[^\/]+/.test(p)) {
else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
// add an extra '' for the one we lose
return ['', ...p.split(/\/+/)];
}
@@ -1080,8 +1087,7 @@ class Minimatch {
filename = ff[i];
}
}
for (let i = 0; i < set.length; i++) {
const pattern = set[i];
for (const pattern of set) {
let file = ff;
if (options.matchBase && pattern.length === 1) {
file = [filename];