1
0
mirror of https://github.com/actions/upload-artifact.git synced 2026-02-26 21:52:30 +00:00

Bump minimatch to 10.1.1

This commit is contained in:
Daniel Kennedy
2026-02-25 13:24:55 -05:00
parent a2008cd1d8
commit 0508a90968
5 changed files with 487 additions and 202 deletions

534
dist/merge/index.js vendored
View File

@ -70854,7 +70854,7 @@ __webpack_unused_export__ = defaultContentType
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Glob = void 0;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
const node_url_1 = __nccwpck_require__(3136);
const path_scurry_1 = __nccwpck_require__(8958);
const pattern_js_1 = __nccwpck_require__(7813);
@ -71107,7 +71107,7 @@ exports.Glob = Glob;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.hasMagic = void 0;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
/**
* Return true if the patterns provided contain any magic glob characters,
* given the options provided.
@ -71144,7 +71144,7 @@ exports.hasMagic = hasMagic;
// Ignores are always parsed in dot:true mode
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Ignore = void 0;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
const pattern_js_1 = __nccwpck_require__(7813);
const defaultPlatform = (typeof process === 'object' &&
process &&
@ -71270,10 +71270,10 @@ exports.globStream = globStream;
exports.globSync = globSync;
exports.globIterateSync = globIterateSync;
exports.globIterate = globIterate;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
const glob_js_1 = __nccwpck_require__(2981);
const has_magic_js_1 = __nccwpck_require__(5197);
var minimatch_2 = __nccwpck_require__(6507);
var minimatch_2 = __nccwpck_require__(3790);
Object.defineProperty(exports, "escape", ({ enumerable: true, get: function () { return minimatch_2.escape; } }));
Object.defineProperty(exports, "unescape", ({ enumerable: true, get: function () { return minimatch_2.unescape; } }));
var glob_js_2 = __nccwpck_require__(2981);
@ -71340,7 +71340,7 @@ exports.glob.glob = exports.glob;
// this is just a very light wrapper around 2 arrays with an offset index
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Pattern = void 0;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
const isPatternList = (pl) => pl.length >= 1;
const isGlobList = (gl) => gl.length >= 1;
/**
@ -71565,7 +71565,7 @@ exports.Pattern = Pattern;
// synchronous utility for filtering entries and calculating subwalks
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.Processor = exports.SubWalks = exports.MatchRecord = exports.HasWalkedCache = void 0;
const minimatch_1 = __nccwpck_require__(6507);
const minimatch_1 = __nccwpck_require__(3790);
/**
* A cache of which patterns have been processed for a given Path
*/
@ -72258,7 +72258,7 @@ exports.GlobStream = GlobStream;
/***/ }),
/***/ 7305:
/***/ 8895:
/***/ ((__unused_webpack_module, exports) => {
@ -72278,7 +72278,7 @@ exports.assertValidPattern = assertValidPattern;
/***/ }),
/***/ 1803:
/***/ 3238:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
@ -72286,8 +72286,8 @@ exports.assertValidPattern = assertValidPattern;
var _a;
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.AST = void 0;
const brace_expressions_js_1 = __nccwpck_require__(1090);
const unescape_js_1 = __nccwpck_require__(851);
const brace_expressions_js_1 = __nccwpck_require__(5192);
const unescape_js_1 = __nccwpck_require__(9829);
const types = new Set(['!', '?', '+', '*', '@']);
const isExtglobType = (c) => types.has(c);
const isExtglobAST = (c) => isExtglobType(c.type);
@ -73031,7 +73031,7 @@ _a = AST;
/***/ }),
/***/ 1090:
/***/ 5192:
/***/ ((__unused_webpack_module, exports) => {
@ -73189,7 +73189,7 @@ exports.parseClass = parseClass;
/***/ }),
/***/ 800:
/***/ 6726:
/***/ ((__unused_webpack_module, exports) => {
@ -73217,17 +73217,17 @@ exports.escape = escape;
/***/ }),
/***/ 6507:
/***/ 3790:
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.unescape = exports.escape = exports.AST = exports.Minimatch = exports.match = exports.makeRe = exports.braceExpand = exports.defaults = exports.filter = exports.GLOBSTAR = exports.sep = exports.minimatch = void 0;
const brace_expansion_1 = __nccwpck_require__(8968);
const assert_valid_pattern_js_1 = __nccwpck_require__(7305);
const ast_js_1 = __nccwpck_require__(1803);
const escape_js_1 = __nccwpck_require__(800);
const unescape_js_1 = __nccwpck_require__(851);
const assert_valid_pattern_js_1 = __nccwpck_require__(8895);
const ast_js_1 = __nccwpck_require__(3238);
const escape_js_1 = __nccwpck_require__(6726);
const unescape_js_1 = __nccwpck_require__(9829);
const minimatch = (p, pattern, options = {}) => {
(0, assert_valid_pattern_js_1.assertValidPattern)(pattern);
// shortcut: comments match nothing.
@ -74228,11 +74228,11 @@ class Minimatch {
}
exports.Minimatch = Minimatch;
/* c8 ignore start */
var ast_js_2 = __nccwpck_require__(1803);
var ast_js_2 = __nccwpck_require__(3238);
Object.defineProperty(exports, "AST", ({ enumerable: true, get: function () { return ast_js_2.AST; } }));
var escape_js_2 = __nccwpck_require__(800);
var escape_js_2 = __nccwpck_require__(6726);
Object.defineProperty(exports, "escape", ({ enumerable: true, get: function () { return escape_js_2.escape; } }));
var unescape_js_2 = __nccwpck_require__(851);
var unescape_js_2 = __nccwpck_require__(9829);
Object.defineProperty(exports, "unescape", ({ enumerable: true, get: function () { return unescape_js_2.unescape; } }));
/* c8 ignore stop */
exports.minimatch.AST = ast_js_1.AST;
@ -74243,7 +74243,7 @@ exports.minimatch.unescape = unescape_js_1.unescape;
/***/ }),
/***/ 851:
/***/ 9829:
/***/ ((__unused_webpack_module, exports) => {
@ -82870,10 +82870,8 @@ const parseClass = (glob, position) => {
}
const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
const comb = ranges.length && negs.length
? '(' + sranges + '|' + snegs + ')'
: ranges.length
? sranges
const comb = ranges.length && negs.length ? '(' + sranges + '|' + snegs + ')'
: ranges.length ? sranges
: snegs;
return [comb, uflag, endPos - pos, true];
};
@ -82882,21 +82880,35 @@ const parseClass = (glob, position) => {
/**
* Un-escape a string that has been escaped with {@link escape}.
*
* If the {@link windowsPathsNoEscape} option is used, then square-brace
* escapes are removed, but not backslash escapes. For example, it will turn
* the string `'[*]'` into `*`, but it will not turn `'\\*'` into `'*'`,
* becuase `\` is a path separator in `windowsPathsNoEscape` mode.
* If the {@link MinimatchOptions.windowsPathsNoEscape} option is used, then
* square-bracket escapes are removed, but not backslash escapes.
*
* When `windowsPathsNoEscape` is not set, then both brace escapes and
* For example, it will turn the string `'[*]'` into `*`, but it will not
* turn `'\\*'` into `'*'`, because `\` is a path separator in
* `windowsPathsNoEscape` mode.
*
* When `windowsPathsNoEscape` is not set, then both square-bracket escapes and
* backslash escapes are removed.
*
* Slashes (and backslashes in `windowsPathsNoEscape` mode) cannot be escaped
* or unescaped.
*
* When `magicalBraces` is not set, escapes of braces (`{` and `}`) will not be
* unescaped.
*/
const unescape_unescape = (s, { windowsPathsNoEscape = false, } = {}) => {
return windowsPathsNoEscape
? s.replace(/\[([^\/\\])\]/g, '$1')
: s.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2').replace(/\\([^\/])/g, '$1');
const unescape_unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true, } = {}) => {
if (magicalBraces) {
return windowsPathsNoEscape ?
s.replace(/\[([^\/\\])\]/g, '$1')
: s
.replace(/((?!\\).|^)\[([^\/\\])\]/g, '$1$2')
.replace(/\\([^\/])/g, '$1');
}
return windowsPathsNoEscape ?
s.replace(/\[([^\/\\{}])\]/g, '$1')
: s
.replace(/((?!\\).|^)\[([^\/\\{}])\]/g, '$1$2')
.replace(/\\([^\/{}])/g, '$1');
};
//# sourceMappingURL=unescape.js.map
;// CONCATENATED MODULE: ./node_modules/minimatch/dist/esm/ast.js
@ -82907,6 +82919,53 @@ var _a;
const types = new Set(['!', '?', '+', '*', '@']);
const isExtglobType = (c) => types.has(c);
const isExtglobAST = (c) => isExtglobType(c.type);
// Map of which extglob types can adopt the children of a nested extglob
//
// anything but ! can adopt a matching type:
// +(a|+(b|c)|d) => +(a|b|c|d)
// *(a|*(b|c)|d) => *(a|b|c|d)
// @(a|@(b|c)|d) => @(a|b|c|d)
// ?(a|?(b|c)|d) => ?(a|b|c|d)
//
// * can adopt anything, because 0 or repetition is allowed
// *(a|?(b|c)|d) => *(a|b|c|d)
// *(a|+(b|c)|d) => *(a|b|c|d)
// *(a|@(b|c)|d) => *(a|b|c|d)
//
// + can adopt @, because 1 or repetition is allowed
// +(a|@(b|c)|d) => +(a|b|c|d)
//
// + and @ CANNOT adopt *, because 0 would be allowed
// +(a|*(b|c)|d) => would match "", on *(b|c)
// @(a|*(b|c)|d) => would match "", on *(b|c)
//
// + and @ CANNOT adopt ?, because 0 would be allowed
// +(a|?(b|c)|d) => would match "", on ?(b|c)
// @(a|?(b|c)|d) => would match "", on ?(b|c)
//
// ? can adopt @, because 0 or 1 is allowed
// ?(a|@(b|c)|d) => ?(a|b|c|d)
//
// ? and @ CANNOT adopt * or +, because >1 would be allowed
// ?(a|*(b|c)|d) => would match bbb on *(b|c)
// @(a|*(b|c)|d) => would match bbb on *(b|c)
// ?(a|+(b|c)|d) => would match bbb on +(b|c)
// @(a|+(b|c)|d) => would match bbb on +(b|c)
//
// ! CANNOT adopt ! (nothing else can either)
// !(a|!(b|c)|d) => !(a|b|c|d) would fail to match on b (not not b|c)
//
// ! can adopt @
// !(a|@(b|c)|d) => !(a|b|c|d)
//
// ! CANNOT adopt *
// !(a|*(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
//
// ! CANNOT adopt +
// !(a|+(b|c)|d) => !(a|b|c|d) would match on bbb, not allowed
//
// ! CANNOT adopt ?
// x!(a|?(b|c)|d) => x!(a|b|c|d) would fail to match "x"
const adoptionMap = new Map([
['!', ['@']],
['?', ['?', '@']],
@ -82914,11 +82973,14 @@ const adoptionMap = new Map([
['*', ['*', '+', '?', '@']],
['+', ['+', '@']],
]);
// nested extglobs that can be adopted in, but with the addition of
// a blank '' element.
const adoptionWithSpaceMap = new Map([
['!', ['?']],
['@', ['?']],
['+', ['?', '*']],
]);
// union of the previous two maps
const adoptionAnyMap = new Map([
['!', ['?', '@']],
['?', ['?', '@']],
@ -82926,11 +82988,36 @@ const adoptionAnyMap = new Map([
['*', ['*', '+', '?', '@']],
['+', ['+', '@', '?', '*']],
]);
// Extglobs that can take over their parent if they are the only child
// the key is parent, value maps child to resulting extglob parent type
// '@' is omitted because it's a special case. An `@` extglob with a single
// member can always be usurped by that subpattern.
const usurpMap = new Map([
['!', new Map([['!', '@']])],
['?', new Map([['*', '*'], ['+', '*']])],
['@', new Map([['!', '!'], ['?', '?'], ['@', '@'], ['*', '*'], ['+', '+']])],
['+', new Map([['?', '*'], ['*', '*']])],
[
'?',
new Map([
['*', '*'],
['+', '*'],
]),
],
[
'@',
new Map([
['!', '!'],
['?', '?'],
['@', '@'],
['*', '*'],
['+', '+'],
]),
],
[
'+',
new Map([
['?', '*'],
['*', '*'],
]),
],
]);
// Patterns that get prepended to bind to the start of either the
// entire string, or just a single path portion, to prevent dots
@ -82955,6 +83042,7 @@ const star = qmark + '*?';
const starNoEmpty = qmark + '+?';
// remove the \ chars that we added if we end up doing a nonmagic compare
// const deslash = (s: string) => s.replace(/\\(.)/g, '$1')
let ID = 0;
class AST {
type;
#root;
@ -82970,6 +83058,22 @@ class AST {
// set to true if it's an extglob with no children
// (which really means one child of '')
#emptyExt = false;
id = ++ID;
get depth() {
return (this.#parent?.depth ?? -1) + 1;
}
[Symbol.for('nodejs.util.inspect.custom')]() {
return {
'@@type': 'AST',
id: this.id,
type: this.type,
root: this.#root.id,
parent: this.#parent?.id,
depth: this.depth,
partsLength: this.#parts.length,
parts: this.#parts,
};
}
constructor(type, parent, options = {}) {
this.type = type;
// extglobs are inherently magical
@ -83048,7 +83152,8 @@ class AST {
if (p === '')
continue;
/* c8 ignore start */
if (typeof p !== 'string' && !(p instanceof _a && p.#parent === this)) {
if (typeof p !== 'string' &&
!(p instanceof _a && p.#parent === this)) {
throw new Error('invalid part: ' + p);
}
/* c8 ignore stop */
@ -83056,8 +83161,10 @@ class AST {
}
}
toJSON() {
const ret = this.type === null
? this.#parts.slice().map(p => (typeof p === 'string' ? p : p.toJSON()))
const ret = this.type === null ?
this.#parts
.slice()
.map(p => (typeof p === 'string' ? p : p.toJSON()))
: [this.type, ...this.#parts.map(p => p.toJSON())];
if (this.isStart() && !this.type)
ret.unshift([]);
@ -83152,6 +83259,8 @@ class AST {
acc += c;
continue;
}
// we don't have to check for adoption here, because that's
// done at the other recursion point.
const doRecurse = !opt.noext &&
isExtglobType(c) &&
str.charAt(i) === '(' &&
@ -83203,7 +83312,8 @@ class AST {
acc += c;
continue;
}
const doRecurse = isExtglobType(c) &&
const doRecurse = !opt.noext &&
isExtglobType(c) &&
str.charAt(i) === '(' &&
/* c8 ignore start - the maxDepth is sufficient here */
(extDepth <= maxDepth || (ast && ast.#canAdoptType(c)));
@ -83308,47 +83418,14 @@ class AST {
/* c8 ignore stop */
this.#parts = gc.#parts;
for (const p of this.#parts) {
if (typeof p === 'object')
if (typeof p === 'object') {
p.#parent = this;
}
}
this.type = nt;
this.#toString = undefined;
this.#emptyExt = false;
}
#flatten() {
if (!isExtglobAST(this)) {
for (const p of this.#parts) {
if (typeof p === 'object')
p.#flatten();
}
}
else {
let iterations = 0;
let done = false;
do {
done = true;
for (let i = 0; i < this.#parts.length; i++) {
const c = this.#parts[i];
if (typeof c === 'object') {
c.#flatten();
if (this.#canAdopt(c)) {
done = false;
this.#adopt(c, i);
}
else if (this.#canAdoptWithSpace(c)) {
done = false;
this.#adoptWithSpace(c, i);
}
else if (this.#canUsurp(c)) {
done = false;
this.#usurp(c);
}
}
}
} while (!done && ++iterations < 10);
}
this.#toString = undefined;
}
static fromGlob(pattern, options = {}) {
const ast = new _a(null, undefined, options);
_a.#parseAST(pattern, ast, 0, options, 0);
@ -83460,11 +83537,13 @@ class AST {
this.#fillNegs();
}
if (!isExtglobAST(this)) {
const noEmpty = this.isStart() && this.isEnd();
const noEmpty = this.isStart() &&
this.isEnd() &&
!this.#parts.some(s => typeof s !== 'string');
const src = this.#parts
.map(p => {
const [re, _, hasMagic, uflag] = typeof p === 'string'
? _a.#parseGlob(p, this.#hasMagic, noEmpty)
const [re, _, hasMagic, uflag] = typeof p === 'string' ?
_a.#parseGlob(p, this.#hasMagic, noEmpty)
: p.toRegExpSource(allowDot);
this.#hasMagic = this.#hasMagic || hasMagic;
this.#uflag = this.#uflag || uflag;
@ -83493,7 +83572,10 @@ class AST {
// no need to prevent dots if it can't match a dot, or if a
// sub-pattern will be preventing it anyway.
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
start = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : '';
start =
needNoTrav ? startNoTraversal
: needNoDot ? startNoDot
: '';
}
}
}
@ -83529,9 +83611,8 @@ class AST {
me.#hasMagic = undefined;
return [s, unescape_unescape(this.toString()), false, false];
}
// XXX abstract out this map method
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot
? ''
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ?
''
: this.#partsToRegExp(true);
if (bodyDotAllowed === body) {
bodyDotAllowed = '';
@ -83545,20 +83626,16 @@ class AST {
final = (this.isStart() && !dot ? startNoDot : '') + starNoEmpty;
}
else {
const close = this.type === '!'
? // !() must match something,but !(x) can match ''
'))' +
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
star +
')'
: this.type === '@'
? ')'
: this.type === '?'
? ')?'
: this.type === '+' && bodyDotAllowed
? ')'
: this.type === '*' && bodyDotAllowed
? `)?`
const close = this.type === '!' ?
// !() must match something,but !(x) can match ''
'))' +
(this.isStart() && !dot && !allowDot ? startNoDot : '') +
star +
')'
: this.type === '@' ? ')'
: this.type === '?' ? ')?'
: this.type === '+' && bodyDotAllowed ? ')'
: this.type === '*' && bodyDotAllowed ? `)?`
: `)${this.type}`;
final = start + body + close;
}
@ -83569,6 +83646,42 @@ class AST {
this.#uflag,
];
}
#flatten() {
if (!isExtglobAST(this)) {
for (const p of this.#parts) {
if (typeof p === 'object') {
p.#flatten();
}
}
}
else {
// do up to 10 passes to flatten as much as possible
let iterations = 0;
let done = false;
do {
done = true;
for (let i = 0; i < this.#parts.length; i++) {
const c = this.#parts[i];
if (typeof c === 'object') {
c.#flatten();
if (this.#canAdopt(c)) {
done = false;
this.#adopt(c, i);
}
else if (this.#canAdoptWithSpace(c)) {
done = false;
this.#adoptWithSpace(c, i);
}
else if (this.#canUsurp(c)) {
done = false;
this.#usurp(c);
}
}
}
} while (!done && ++iterations < 10);
}
this.#toString = undefined;
}
#partsToRegExp(dot) {
return this.#parts
.map(p => {
@ -83597,9 +83710,19 @@ class AST {
if (escaping) {
escaping = false;
re += (reSpecials.has(c) ? '\\' : '') + c;
inStar = false;
continue;
}
if (c === '*') {
if (inStar)
continue;
inStar = true;
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
hasMagic = true;
continue;
}
else {
inStar = false;
}
if (c === '\\') {
if (i === glob.length - 1) {
re += '\\\\';
@ -83616,21 +83739,9 @@ class AST {
uflag = uflag || needUflag;
i += consumed - 1;
hasMagic = hasMagic || magic;
inStar = false;
continue;
}
}
if (c === '*') {
if (inStar)
continue;
inStar = true;
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
hasMagic = true;
continue;
}
else {
inStar = false;
}
if (c === '?') {
re += qmark;
hasMagic = true;
@ -83647,18 +83758,26 @@ _a = AST;
/**
* Escape all magic characters in a glob pattern.
*
* If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
* If the {@link MinimatchOptions.windowsPathsNoEscape}
* option is used, then characters are escaped by wrapping in `[]`, because
* a magic character wrapped in a character class can only be satisfied by
* that exact character. In this mode, `\` is _not_ escaped, because it is
* not interpreted as a magic character, but instead as a path separator.
*
* If the {@link MinimatchOptions.magicalBraces} option is used,
* then braces (`{` and `}`) will be escaped.
*/
const escape_escape = (s, { windowsPathsNoEscape = false, } = {}) => {
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false, } = {}) => {
// don't need to escape +@! because we escape the parens
// that make those magic, and escaping ! as [!] isn't valid,
// because [!]] is a valid glob class meaning not ']'.
return windowsPathsNoEscape
? s.replace(/[?*()[\]]/g, '[$&]')
if (magicalBraces) {
return windowsPathsNoEscape ?
s.replace(/[?*()[\]{}]/g, '[$&]')
: s.replace(/[?*()[\]\\{}]/g, '\\$&');
}
return windowsPathsNoEscape ?
s.replace(/[?*()[\]]/g, '[$&]')
: s.replace(/[?*()[\]\\]/g, '\\$&');
};
//# sourceMappingURL=escape.js.map
@ -83728,8 +83847,8 @@ const qmarksTestNoExtDot = ([$0]) => {
return (f) => f.length === len && f !== '.' && f !== '..';
};
/* c8 ignore start */
const defaultPlatform = (typeof process === 'object' && process
? (typeof process.env === 'object' &&
const defaultPlatform = (typeof process === 'object' && process ?
(typeof process.env === 'object' &&
process.env &&
process.env.__MINIMATCH_TESTING_PLATFORM__) ||
process.platform
@ -83813,7 +83932,7 @@ const braceExpand = (pattern, options = {}) => {
// shortcut. no need to expand.
return [pattern];
}
return expand(pattern);
return expand(pattern, { max: options.braceExpandMax });
};
minimatch.braceExpand = braceExpand;
// parse a component of the expanded set.
@ -83868,8 +83987,10 @@ class Minimatch {
this.pattern = pattern;
this.platform = options.platform || defaultPlatform;
this.isWindows = this.platform === 'win32';
// avoid the annoying deprecation flag lol
const awe = ('allowWindow' + 'sEscape');
this.windowsPathsNoEscape =
!!options.windowsPathsNoEscape || options.allowWindowsEscape === false;
!!options.windowsPathsNoEscape || options[awe] === false;
if (this.windowsPathsNoEscape) {
this.pattern = this.pattern.replace(/\\/g, '/');
}
@ -83882,8 +84003,8 @@ class Minimatch {
this.partial = !!options.partial;
this.nocase = !!this.options.nocase;
this.windowsNoMagicRoot =
options.windowsNoMagicRoot !== undefined
? options.windowsNoMagicRoot
options.windowsNoMagicRoot !== undefined ?
options.windowsNoMagicRoot
: !!(this.isWindows && this.nocase);
this.globSet = [];
this.globParts = [];
@ -83946,7 +84067,10 @@ class Minimatch {
!globMagic.test(s[3]);
const isDrive = /^[a-z]:/i.test(s[0]);
if (isUNC) {
return [...s.slice(0, 4), ...s.slice(4).map(ss => this.parse(ss))];
return [
...s.slice(0, 4),
...s.slice(4).map(ss => this.parse(ss)),
];
}
else if (isDrive) {
return [s[0], ...s.slice(1).map(ss => this.parse(ss))];
@ -83978,7 +84102,7 @@ class Minimatch {
// to the right as possible, even if it increases the number
// of patterns that we have to process.
preprocess(globParts) {
// if we're not in globstar mode, then turn all ** into *
// 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++) {
@ -84283,13 +84407,18 @@ class Minimatch {
pattern[2] === '?' &&
typeof pattern[3] === 'string' &&
/^[a-z]:$/i.test(pattern[3]);
const fdi = fileUNC ? 3 : fileDrive ? 0 : undefined;
const pdi = patternUNC ? 3 : patternDrive ? 0 : undefined;
const fdi = fileUNC ? 3
: fileDrive ? 0
: undefined;
const pdi = patternUNC ? 3
: patternDrive ? 0
: undefined;
if (typeof fdi === 'number' && typeof pdi === 'number') {
const [fd, pd] = [
file[fdi],
pattern[pdi],
];
// start matching at the drive letter index of each
if (fd.toLowerCase() === pd.toLowerCase()) {
pattern[pdi] = fd;
patternStartIndex = pdi;
@ -84298,7 +84427,7 @@ class Minimatch {
}
}
// resolve and reduce . and .. portions in the file as well.
// dont' need to do the second phase, because it's only one string[]
// don't need to do the second phase, because it's only one string[]
const { optimizationLevel = 1 } = this.options;
if (optimizationLevel >= 2) {
file = this.levelTwoFileOptimize(file);
@ -84309,8 +84438,12 @@ class Minimatch {
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
}
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
// split the pattern into head, tail, and middle of ** delimited parts
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
const lastgs = pattern.lastIndexOf(GLOBSTAR);
// 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),
@ -84320,43 +84453,70 @@ class Minimatch {
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);
if (!this.#matchOne(fileHead, head, partial, 0, 0))
if (!this.#matchOne(fileHead, head, partial, 0, 0)) {
return false;
}
fileIndex += head.length;
patternIndex += head.length;
}
// now we know the head matches!
// if the last portion is not empty, it MUST match the end
// check the tail
let fileTailMatch = 0;
if (tail.length) {
// if head + tail > file, then we cannot possibly match
if (tail.length + fileIndex > file.length)
return false;
// try to match the tail
let tailStart = file.length - tail.length;
if (this.#matchOne(file, tail, partial, tailStart, 0)) {
fileTailMatch = tail.length;
}
else {
// affordance for stuff like a/**/* matching a/b/
// if the last file portion is '', and there's more to the pattern
// then try without the '' bit.
if (file[file.length - 1] !== '' ||
fileIndex + tail.length === file.length) {
return false;
}
tailStart--;
if (!this.#matchOne(file, tail, partial, tailStart, 0))
if (!this.#matchOne(file, tail, partial, tailStart, 0)) {
return false;
}
fileTailMatch = tail.length + 1;
}
}
// now we know the tail matches!
// the middle is zero or more portions wrapped in **, possibly
// containing more ** sections.
// so a/**/b/**/c/**/d has become **/b/**/c/**
// if it's empty, it means a/**/b, just verify we have no bad dots
// if there's no tail, so it ends on /**, then we must have *something*
// after the head, or it's not a matc
if (!body.length) {
let sawSome = !!fileTailMatch;
for (let i = fileIndex; i < file.length - fileTailMatch; i++) {
const f = String(file[i]);
sawSome = true;
if (f === '.' || f === '..' ||
if (f === '.' ||
f === '..' ||
(!this.options.dot && f.startsWith('.'))) {
return false;
}
}
// in partial mode, we just need to get past all file parts
return partial || sawSome;
}
// now we know that there's one or more body sections, which can
// be matched anywhere from the 0 index (because the head was pruned)
// through to the length-fileTailMatch index.
// split the body up into sections, and note the minimum index it can
// be found at (start with the length of all previous segments)
// [section, before, after]
const bodySegments = [[[], 0]];
let currentBody = bodySegments[0];
let nonGsParts = 0;
@ -84379,34 +84539,56 @@ class Minimatch {
}
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
}
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
// return false for "nope, not matching"
// return null for "not matching, cannot keep trying"
#matchGlobStarBodySections(file,
// pattern section, last possible position for it
bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
// take the first body segment, and walk from fileIndex to its "after"
// value at the end
// If it doesn't match at that position, we increment, until we hit
// that final possible position, and give up.
// If it does match, then advance and try to rest.
// If any of them fail we keep walking forward.
// this is still a bit recursively painful, but it's more constrained
// than previous implementations, because we never test something that
// can't possibly be a valid matching condition.
const bs = bodySegments[bodyIndex];
if (!bs) {
// just make sure that there's no bad dots
for (let i = fileIndex; i < file.length; i++) {
sawTail = true;
const f = file[i];
if (f === '.' || f === '..' ||
if (f === '.' ||
f === '..' ||
(!this.options.dot && f.startsWith('.'))) {
return false;
}
}
return sawTail;
}
// have a non-globstar body section to test
const [body, after] = bs;
while (fileIndex <= after) {
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
// if limit exceeded, no match. intentional false negative,
// acceptable break in correctness for security.
if (m && globStarDepth < this.maxGlobstarRecursion) {
// match! see if the rest match. if so, we're done!
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
if (sub !== false)
if (sub !== false) {
return sub;
}
}
const f = file[fileIndex];
if (f === '.' || f === '..' ||
if (f === '.' ||
f === '..' ||
(!this.options.dot && f.startsWith('.'))) {
return false;
}
fileIndex++;
}
// walked off. no point continuing
return partial || null;
}
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
@ -84414,16 +84596,24 @@ class Minimatch {
let pi;
let pl;
let fl;
for (fi = fileIndex, pi = patternIndex,
fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
for (fi = fileIndex,
pi = patternIndex,
fl = file.length,
pl = pattern.length; fi < fl && pi < pl; fi++, pi++) {
this.debug('matchOne loop');
let p = pattern[pi];
let f = file[fi];
this.debug(pattern, p, f);
// should be impossible.
// some invalid regexp stuff in the set.
/* c8 ignore start */
if (p === false || p === GLOBSTAR)
if (p === false || p === GLOBSTAR) {
return false;
}
/* c8 ignore stop */
// something other than **
// non-magic patterns just have to match exactly
// patterns with magic have been turned into regexps.
let hit;
if (typeof p === 'string') {
hit = f === p;
@ -84436,17 +84626,38 @@ class Minimatch {
if (!hit)
return false;
}
// Note: ending in / means that we'll get a final ""
// at the end of the pattern. This can only match a
// corresponding "" at the end of the file.
// If the file ends in /, then it can only match a
// a pattern that ends in /, unless the pattern just
// doesn't have any more for it. But, a/b/ should *not*
// match "a/b/*", even though "" matches against the
// [^/]*? pattern, except in partial mode, where it might
// simply not be reached yet.
// However, a/b/ should still satisfy a/*
// now either we fell off the end of the pattern, or we're done.
if (fi === fl && pi === pl) {
// ran out of pattern and filename at the same time.
// an exact hit!
return true;
}
else if (fi === fl) {
// ran out of file, but still had pattern left.
// this is ok if we're doing the match as part of
// a glob fs traversal.
return partial;
}
else if (pi === pl) {
// ran out of pattern, still have file left.
// this is only acceptable if we're on the very last
// empty segment of a file with a trailing slash.
// a/* should match a/b/
return fi === fl - 1 && file[fi] === '';
/* c8 ignore start */
}
else {
// should be unreachable.
throw new Error('wtf?');
}
/* c8 ignore stop */
@ -84470,21 +84681,19 @@ class Minimatch {
fastTest = options.dot ? starTestDot : starTest;
}
else if ((m = pattern.match(starDotExtRE))) {
fastTest = (options.nocase
? options.dot
? starDotExtTestNocaseDot
fastTest = (options.nocase ?
options.dot ?
starDotExtTestNocaseDot
: starDotExtTestNocase
: options.dot
? starDotExtTestDot
: options.dot ? starDotExtTestDot
: starDotExtTest)(m[1]);
}
else if ((m = pattern.match(qmarksRE))) {
fastTest = (options.nocase
? options.dot
? qmarksTestNocaseDot
fastTest = (options.nocase ?
options.dot ?
qmarksTestNocaseDot
: qmarksTestNocase
: options.dot
? qmarksTestDot
: options.dot ? qmarksTestDot
: qmarksTest)(m);
}
else if ((m = pattern.match(starDotStarRE))) {
@ -84515,10 +84724,8 @@ class Minimatch {
return this.regexp;
}
const options = this.options;
const twoStar = options.noglobstar
? esm_star
: options.dot
? twoStarDot
const twoStar = options.noglobstar ? esm_star
: options.dot ? twoStarDot
: twoStarNoDot;
const flags = new Set(options.nocase ? ['i'] : []);
// regexpify non-globstar patterns
@ -84534,11 +84741,9 @@ class Minimatch {
for (const f of p.flags.split(''))
flags.add(f);
}
return typeof p === 'string'
? esm_regExpEscape(p)
: p === GLOBSTAR
? GLOBSTAR
: p._src;
return (typeof p === 'string' ? esm_regExpEscape(p)
: p === GLOBSTAR ? GLOBSTAR
: p._src);
});
pp.forEach((p, i) => {
const next = pp[i + 1];
@ -84555,14 +84760,25 @@ class Minimatch {
}
}
else if (next === undefined) {
pp[i - 1] = prev + '(?:\\/|' + twoStar + ')?';
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + ')?';
}
else if (next !== GLOBSTAR) {
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
pp[i + 1] = GLOBSTAR;
}
});
return pp.filter(p => p !== GLOBSTAR).join('/');
const filtered = pp.filter(p => p !== GLOBSTAR);
// For partial matches, we need to make the pattern match
// any prefix of the full path. We do this by generating
// alternative patterns that match progressively longer prefixes.
if (this.partial && filtered.length >= 1) {
const prefixes = [];
for (let i = 1; i <= filtered.length; i++) {
prefixes.push(filtered.slice(0, i).join('/'));
}
return '(?:' + prefixes.join('|') + ')';
}
return filtered.join('/');
})
.join('|');
// need to wrap in parens if we had more than one thing with |,
@ -84571,6 +84787,10 @@ class Minimatch {
// must match entire pattern
// ending in a * or ** will make it less strict.
re = '^' + open + re + close + '$';
// In partial mode, '/' should always match as it's a valid prefix for any pattern
if (this.partial) {
re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
}
// can match anything, as long as it's not this.
if (this.negate)
re = '^(?!' + re + ').+$';