Skip to content

Commit 07d7cb7

Browse files
nodejs-github-botaduh95
authored andcommitted
deps: update minimatch to 10.2.6
PR-URL: #64945 Reviewed-By: Daeyeon Jeong <daeyeon.dev@gmail.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent f7d5635 commit 07d7cb7

3 files changed

Lines changed: 814 additions & 1203 deletions

File tree

deps/minimatch/index.js

Lines changed: 128 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"use strict";
22
var __getOwnPropNames = Object.getOwnPropertyNames;
33
var __commonJS = (cb, mod) => function __require() {
4-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4+
try {
5+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6+
} catch (e) {
7+
throw mod = 0, e;
8+
}
59
};
610

711
// node_modules/balanced-match/dist/commonjs/index.js
@@ -71,7 +75,7 @@ var require_commonjs2 = __commonJS({
7175
"node_modules/brace-expansion/dist/commonjs/index.js"(exports2) {
7276
"use strict";
7377
Object.defineProperty(exports2, "__esModule", { value: true });
74-
exports2.EXPANSION_MAX = void 0;
78+
exports2.EXPANSION_MAX_LENGTH = exports2.EXPANSION_MAX = void 0;
7579
exports2.expand = expand;
7680
var balanced_match_1 = require_commonjs();
7781
var escSlash = "\0SLASH" + Math.random() + "\0";
@@ -90,6 +94,7 @@ var require_commonjs2 = __commonJS({
9094
var commaPattern = /\\,/g;
9195
var periodPattern = /\\\./g;
9296
exports2.EXPANSION_MAX = 1e5;
97+
exports2.EXPANSION_MAX_LENGTH = 4e6;
9398
function numeric(str) {
9499
return !isNaN(str) ? parseInt(str, 10) : str.charCodeAt(0);
95100
}
@@ -124,11 +129,11 @@ var require_commonjs2 = __commonJS({
124129
if (!str) {
125130
return [];
126131
}
127-
const { max = exports2.EXPANSION_MAX } = options;
132+
const { max = exports2.EXPANSION_MAX, maxLength = exports2.EXPANSION_MAX_LENGTH } = options;
128133
if (str.slice(0, 2) === "{}") {
129134
str = "\\{\\}" + str.slice(2);
130135
}
131-
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
136+
return expand_(escapeBraces(str), max, maxLength, true).map(unescapeBraces);
132137
}
133138
function embrace(str) {
134139
return "{" + str + "}";
@@ -142,95 +147,147 @@ var require_commonjs2 = __commonJS({
142147
function gte(i, y) {
143148
return i >= y;
144149
}
145-
function expand_(str, max, isTop) {
146-
const expansions = [];
147-
const m = (0, balanced_match_1.balanced)("{", "}", str);
148-
if (!m)
149-
return [str];
150-
const pre = m.pre;
151-
const post = m.post.length ? expand_(m.post, max, false) : [""];
152-
if (/\$$/.test(m.pre)) {
153-
for (let k = 0; k < post.length && k < max; k++) {
154-
const expansion = pre + "{" + m.body + "}" + post[k];
155-
expansions.push(expansion);
150+
function combine(acc, pre, values, max, maxLength, dropEmpties) {
151+
const out = [];
152+
let length = 0;
153+
for (let a = 0; a < acc.length; a++) {
154+
for (let v = 0; v < values.length; v++) {
155+
if (out.length >= max)
156+
return out;
157+
const expansion = acc[a] + pre + values[v];
158+
if (dropEmpties && !expansion)
159+
continue;
160+
if (length + expansion.length > maxLength)
161+
return out;
162+
out.push(expansion);
163+
length += expansion.length;
164+
}
165+
}
166+
return out;
167+
}
168+
function expandSequence(body, isAlphaSequence, max, maxLength) {
169+
const n = body.split(/\.\./);
170+
const N = [];
171+
if (n[0] === void 0 || n[1] === void 0) {
172+
return N;
173+
}
174+
const x = numeric(n[0]);
175+
const y = numeric(n[1]);
176+
const width = Math.max(n[0].length, n[1].length);
177+
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
178+
let test = lte;
179+
const reverse = y < x;
180+
if (reverse) {
181+
incr *= -1;
182+
test = gte;
183+
}
184+
const pad = n.some(isPadded);
185+
let length = 0;
186+
for (let i = x; test(i, y) && N.length < max; i += incr) {
187+
let c;
188+
if (isAlphaSequence) {
189+
c = String.fromCharCode(i);
190+
if (c === "\\") {
191+
c = "";
192+
}
193+
} else {
194+
c = String(i);
195+
if (pad) {
196+
const need = width - c.length;
197+
if (need > 0) {
198+
const z = new Array(need + 1).join("0");
199+
if (i < 0) {
200+
c = "-" + z + c.slice(1);
201+
} else {
202+
c = z + c;
203+
}
204+
}
205+
}
206+
}
207+
if (length + c.length > maxLength)
208+
break;
209+
N.push(c);
210+
length += c.length;
211+
}
212+
return N;
213+
}
214+
function expand_(str, max, maxLength, isTop) {
215+
let acc = [""];
216+
let dropEmpties = false;
217+
let firstGroup = true;
218+
for (; ; ) {
219+
const m = (0, balanced_match_1.balanced)("{", "}", str);
220+
if (!m) {
221+
return combine(acc, str, [""], max, maxLength, dropEmpties);
222+
}
223+
const pre = m.pre;
224+
if (/\$$/.test(pre)) {
225+
acc = combine(acc, pre + "{" + m.body + "}", [""], max, maxLength, dropEmpties && !m.post.length);
226+
firstGroup = false;
227+
if (!m.post.length)
228+
break;
229+
str = m.post;
230+
continue;
156231
}
157-
} else {
158232
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
159233
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
160234
const isSequence = isNumericSequence || isAlphaSequence;
161235
const isOptions = m.body.indexOf(",") >= 0;
162236
if (!isSequence && !isOptions) {
163237
if (m.post.match(/,(?!,).*\}/)) {
164238
str = m.pre + "{" + m.body + escClose + m.post;
165-
return expand_(str, max, true);
239+
isTop = true;
240+
continue;
166241
}
167-
return [str];
242+
return combine(acc, pre + "{" + m.body + "}" + m.post, [""], max, maxLength, dropEmpties);
168243
}
169-
let n;
244+
if (firstGroup) {
245+
dropEmpties = isTop && !isSequence;
246+
firstGroup = false;
247+
}
248+
let values;
170249
if (isSequence) {
171-
n = m.body.split(/\.\./);
250+
values = expandSequence(m.body, isAlphaSequence, max, maxLength);
172251
} else {
173-
n = parseCommaParts(m.body);
252+
let n = parseCommaParts(m.body);
174253
if (n.length === 1 && n[0] !== void 0) {
175-
n = expand_(n[0], max, false).map(embrace);
254+
n = expand_(n[0], max, maxLength, false).map(embrace);
176255
if (n.length === 1) {
177-
return post.map((p) => m.pre + n[0] + p);
256+
acc = combine(acc, pre + n[0], [""], max, maxLength, dropEmpties && !m.post.length);
257+
if (!m.post.length)
258+
break;
259+
str = m.post;
260+
continue;
178261
}
179262
}
180-
}
181-
let N;
182-
if (isSequence && n[0] !== void 0 && n[1] !== void 0) {
183-
const x = numeric(n[0]);
184-
const y = numeric(n[1]);
185-
const width = Math.max(n[0].length, n[1].length);
186-
let incr = n.length === 3 && n[2] !== void 0 ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
187-
let test = lte;
188-
const reverse = y < x;
189-
if (reverse) {
190-
incr *= -1;
191-
test = gte;
192-
}
193-
const pad = n.some(isPadded);
194-
N = [];
195-
for (let i = x; test(i, y); i += incr) {
196-
let c;
197-
if (isAlphaSequence) {
198-
c = String.fromCharCode(i);
199-
if (c === "\\") {
200-
c = "";
201-
}
202-
} else {
203-
c = String(i);
204-
if (pad) {
205-
const need = width - c.length;
206-
if (need > 0) {
207-
const z = new Array(need + 1).join("0");
208-
if (i < 0) {
209-
c = "-" + z + c.slice(1);
210-
} else {
211-
c = z + c;
212-
}
213-
}
214-
}
263+
let dropsEmpties = dropEmpties && !m.post.length && !pre;
264+
for (let d = 0; dropsEmpties && d < acc.length; d++) {
265+
if (acc[d]) {
266+
dropsEmpties = false;
215267
}
216-
N.push(c);
217-
}
218-
} else {
219-
N = [];
220-
for (let j = 0; j < n.length; j++) {
221-
N.push.apply(N, expand_(n[j], max, false));
222268
}
223-
}
224-
for (let j = 0; j < N.length; j++) {
225-
for (let k = 0; k < post.length && expansions.length < max; k++) {
226-
const expansion = pre + N[j] + post[k];
227-
if (!isTop || isSequence || expansion) {
228-
expansions.push(expansion);
269+
values = [];
270+
let valuesLength = 0;
271+
outer: for (let j = 0; j < n.length; j++) {
272+
const expanded = expand_(n[j], max, maxLength, false);
273+
for (let k = 0; k < expanded.length; k++) {
274+
const v = expanded[k];
275+
if (dropsEmpties && !v)
276+
continue;
277+
if (values.length >= max || valuesLength + v.length > maxLength) {
278+
break outer;
279+
}
280+
values.push(v);
281+
valuesLength += v.length;
229282
}
230283
}
231284
}
285+
acc = combine(acc, pre, values, max, maxLength, dropEmpties && !m.post.length);
286+
if (!m.post.length)
287+
break;
288+
str = m.post;
232289
}
233-
return expansions;
290+
return acc;
234291
}
235292
}
236293
});

0 commit comments

Comments
 (0)