Skip to content

Commit f43d718

Browse files
nodejs-github-botRafaelGSS
authored andcommitted
deps: update minimatch to 9.0.2
PR-URL: #48542 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
1 parent 2f66147 commit f43d718

File tree

11 files changed

+135
-85
lines changed

11 files changed

+135
-85
lines changed

deps/minimatch/index.js

+31-17
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ var require_ast = __commonJS({
403403
var unescape_js_12 = require_unescape();
404404
var types = /* @__PURE__ */ new Set(["!", "?", "+", "*", "@"]);
405405
var isExtglobType = (c) => types.has(c);
406-
var startNoTraversal = "(?!\\.\\.?(?:$|/))";
406+
var startNoTraversal = "(?!(?:^|/)\\.\\.?(?:$|/))";
407407
var startNoDot = "(?!\\.)";
408408
var addPatternStart = /* @__PURE__ */ new Set(["[", "."]);
409409
var justDots = /* @__PURE__ */ new Set(["..", "."]);
@@ -412,10 +412,11 @@ var require_ast = __commonJS({
412412
var qmark2 = "[^/]";
413413
var star2 = qmark2 + "*?";
414414
var starNoEmpty = qmark2 + "+?";
415-
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _fillNegs, fillNegs_fn, _parseAST, parseAST_fn, _parseGlob, parseGlob_fn;
415+
var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _fillNegs, fillNegs_fn, _parseAST, parseAST_fn, _partsToRegExp, partsToRegExp_fn, _parseGlob, parseGlob_fn;
416416
var _AST = class {
417417
constructor(type, parent, options = {}) {
418418
__privateAdd(this, _fillNegs);
419+
__privateAdd(this, _partsToRegExp);
419420
__publicField(this, "type");
420421
__privateAdd(this, _root, void 0);
421422
__privateAdd(this, _hasMagic, void 0);
@@ -614,14 +615,15 @@ var require_ast = __commonJS({
614615
// - Since the start for a join is eg /(?!\.) and the start for a part
615616
// is ^(?!\.), we can just prepend (?!\.) to the pattern (either root
616617
// or start or whatever) and prepend ^ or / at the Regexp construction.
617-
toRegExpSource() {
618+
toRegExpSource(allowDot) {
619+
const dot = allowDot ?? !!__privateGet(this, _options).dot;
618620
if (__privateGet(this, _root) === this)
619621
__privateMethod(this, _fillNegs, fillNegs_fn).call(this);
620622
if (!this.type) {
621623
const noEmpty = this.isStart() && this.isEnd();
622624
const src = __privateGet(this, _parts).map((p) => {
623625
var _a;
624-
const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a = _AST, _parseGlob, parseGlob_fn).call(_a, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource();
626+
const [re, _, hasMagic, uflag] = typeof p === "string" ? __privateMethod(_a = _AST, _parseGlob, parseGlob_fn).call(_a, p, __privateGet(this, _hasMagic), noEmpty) : p.toRegExpSource(allowDot);
625627
__privateSet(this, _hasMagic, __privateGet(this, _hasMagic) || hasMagic);
626628
__privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
627629
return re;
@@ -634,11 +636,11 @@ var require_ast = __commonJS({
634636
const aps = addPatternStart;
635637
const needNoTrav = (
636638
// dots are allowed, and the pattern starts with [ or .
637-
__privateGet(this, _options).dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
639+
dot && aps.has(src.charAt(0)) || // the pattern starts with \., and then [ or .
638640
src.startsWith("\\.") && aps.has(src.charAt(2)) || // the pattern starts with \.\., and then [ or .
639641
src.startsWith("\\.\\.") && aps.has(src.charAt(4))
640642
);
641-
const needNoDot = !__privateGet(this, _options).dot && aps.has(src.charAt(0));
643+
const needNoDot = !dot && !allowDot && aps.has(src.charAt(0));
642644
start2 = needNoTrav ? startNoTraversal : needNoDot ? startNoDot : "";
643645
}
644646
}
@@ -655,30 +657,31 @@ var require_ast = __commonJS({
655657
__privateGet(this, _uflag)
656658
];
657659
}
660+
const repeated = this.type === "*" || this.type === "+";
658661
const start = this.type === "!" ? "(?:(?!(?:" : "(?:";
659-
const body = __privateGet(this, _parts).map((p) => {
660-
if (typeof p === "string") {
661-
throw new Error("string type in extglob ast??");
662-
}
663-
const [re, _, _hasMagic2, uflag] = p.toRegExpSource();
664-
__privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
665-
return re;
666-
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
662+
let body = __privateMethod(this, _partsToRegExp, partsToRegExp_fn).call(this, dot);
667663
if (this.isStart() && this.isEnd() && !body && this.type !== "!") {
668664
const s = this.toString();
669665
__privateSet(this, _parts, [s]);
670666
this.type = null;
671667
__privateSet(this, _hasMagic, void 0);
672668
return [s, (0, unescape_js_12.unescape)(this.toString()), false, false];
673669
}
670+
let bodyDotAllowed = !repeated || allowDot || dot || !startNoDot ? "" : __privateMethod(this, _partsToRegExp, partsToRegExp_fn).call(this, true);
671+
if (bodyDotAllowed === body) {
672+
bodyDotAllowed = "";
673+
}
674+
if (bodyDotAllowed) {
675+
body = `(?:${body})(?:${bodyDotAllowed})*?`;
676+
}
674677
let final = "";
675678
if (this.type === "!" && __privateGet(this, _emptyExt)) {
676-
final = (this.isStart() && !__privateGet(this, _options).dot ? startNoDot : "") + starNoEmpty;
679+
final = (this.isStart() && !dot ? startNoDot : "") + starNoEmpty;
677680
} else {
678681
const close = this.type === "!" ? (
679682
// !() must match something,but !(x) can match ''
680-
"))" + (this.isStart() && !__privateGet(this, _options).dot ? startNoDot : "") + star2 + ")"
681-
) : this.type === "@" ? ")" : `)${this.type}`;
683+
"))" + (this.isStart() && !dot && !allowDot ? startNoDot : "") + star2 + ")"
684+
) : this.type === "@" ? ")" : this.type === "?" ? ")?" : this.type === "+" && bodyDotAllowed ? ")" : this.type === "*" && bodyDotAllowed ? `)?` : `)${this.type}`;
682685
final = start + body + close;
683686
}
684687
return [
@@ -836,6 +839,17 @@ var require_ast = __commonJS({
836839
__privateSet(ast, _parts, [str.substring(pos - 1)]);
837840
return i;
838841
};
842+
_partsToRegExp = new WeakSet();
843+
partsToRegExp_fn = function(dot) {
844+
return __privateGet(this, _parts).map((p) => {
845+
if (typeof p === "string") {
846+
throw new Error("string type in extglob ast??");
847+
}
848+
const [re, _, _hasMagic2, uflag] = p.toRegExpSource(dot);
849+
__privateSet(this, _uflag, __privateGet(this, _uflag) || uflag);
850+
return re;
851+
}).filter((p) => !(this.isStart() && this.isEnd()) || !!p).join("|");
852+
};
839853
_parseGlob = new WeakSet();
840854
parseGlob_fn = function(glob, hasMagic, noEmpty = false) {
841855
let escaping = false;

deps/minimatch/src/dist/cjs/ast.d.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ export declare class AST {
1414
clone(parent: AST): AST;
1515
static fromGlob(pattern: string, options?: MinimatchOptions): AST;
1616
toMMPattern(): MMRegExp | string;
17-
toRegExpSource(): [
18-
re: string,
19-
body: string,
20-
hasMagic: boolean,
21-
uflag: boolean
22-
];
17+
toRegExpSource(allowDot?: boolean): [re: string, body: string, hasMagic: boolean, uflag: boolean];
2318
}
2419
//# sourceMappingURL=ast.d.ts.map

deps/minimatch/src/dist/cjs/ast.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

deps/minimatch/src/dist/cjs/ast.js

+47-24
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/minimatch/src/dist/cjs/ast.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deps/minimatch/src/dist/mjs/ast.d.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@ export declare class AST {
1414
clone(parent: AST): AST;
1515
static fromGlob(pattern: string, options?: MinimatchOptions): AST;
1616
toMMPattern(): MMRegExp | string;
17-
toRegExpSource(): [
18-
re: string,
19-
body: string,
20-
hasMagic: boolean,
21-
uflag: boolean
22-
];
17+
toRegExpSource(allowDot?: boolean): [re: string, body: string, hasMagic: boolean, uflag: boolean];
2318
}
2419
//# sourceMappingURL=ast.d.ts.map

deps/minimatch/src/dist/mjs/ast.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

0 commit comments

Comments
 (0)