Skip to content

Commit a6da22a

Browse files
committed
1 parent 55955fd commit a6da22a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3435
-13
lines changed

node_modules/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
!/iconv-lite
117117
!/ieee754
118118
!/ignore-walk
119+
!/ignore-walk/node_modules/
120+
/ignore-walk/node_modules/*
121+
!/ignore-walk/node_modules/minimatch
119122
!/imurmurhash
120123
!/indent-string
121124
!/infer-owner
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The ISC License
2+
3+
Copyright (c) 2011-2023 Isaac Z. Schlueter and Contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export type ParseClassResult = [
2+
src: string,
3+
uFlag: boolean,
4+
consumed: number,
5+
hasMagic: boolean
6+
];
7+
export declare const parseClass: (glob: string, position: number) => ParseClassResult;
8+
//# sourceMappingURL=brace-expressions.d.ts.map
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":3,"file":"brace-expressions.d.ts","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,OAAO;IACd,QAAQ,EAAE,MAAM;IAChB,QAAQ,EAAE,OAAO;CAClB,CAAA;AAQD,eAAO,MAAM,UAAU,SACf,MAAM,YACF,MAAM,qBA8HjB,CAAA"}
Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
"use strict";
2+
// translate the various posix character classes into unicode properties
3+
// this works across all unicode locales
4+
Object.defineProperty(exports, "__esModule", { value: true });
5+
exports.parseClass = void 0;
6+
// { <posix class>: [<translation>, /u flag required, negated]
7+
const posixClasses = {
8+
'[:alnum:]': ['\\p{L}\\p{Nl}\\p{Nd}', true],
9+
'[:alpha:]': ['\\p{L}\\p{Nl}', true],
10+
'[:ascii:]': ['\\x' + '00-\\x' + '7f', false],
11+
'[:blank:]': ['\\p{Zs}\\t', true],
12+
'[:cntrl:]': ['\\p{Cc}', true],
13+
'[:digit:]': ['\\p{Nd}', true],
14+
'[:graph:]': ['\\p{Z}\\p{C}', true, true],
15+
'[:lower:]': ['\\p{Ll}', true],
16+
'[:print:]': ['\\p{C}', true],
17+
'[:punct:]': ['\\p{P}', true],
18+
'[:space:]': ['\\p{Z}\\t\\r\\n\\v\\f', true],
19+
'[:upper:]': ['\\p{Lu}', true],
20+
'[:word:]': ['\\p{L}\\p{Nl}\\p{Nd}\\p{Pc}', true],
21+
'[:xdigit:]': ['A-Fa-f0-9', false],
22+
};
23+
// only need to escape a few things inside of brace expressions
24+
// escapes: [ \ ] -
25+
const braceEscape = (s) => s.replace(/[[\]\\-]/g, '\\$&');
26+
// escape all regexp magic characters
27+
const regexpEscape = (s) => s.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
28+
// everything has already been escaped, we just have to join
29+
const rangesToString = (ranges) => ranges.join('');
30+
// takes a glob string at a posix brace expression, and returns
31+
// an equivalent regular expression source, and boolean indicating
32+
// whether the /u flag needs to be applied, and the number of chars
33+
// consumed to parse the character class.
34+
// This also removes out of order ranges, and returns ($.) if the
35+
// entire class just no good.
36+
const parseClass = (glob, position) => {
37+
const pos = position;
38+
/* c8 ignore start */
39+
if (glob.charAt(pos) !== '[') {
40+
throw new Error('not in a brace expression');
41+
}
42+
/* c8 ignore stop */
43+
const ranges = [];
44+
const negs = [];
45+
let i = pos + 1;
46+
let sawStart = false;
47+
let uflag = false;
48+
let escaping = false;
49+
let negate = false;
50+
let endPos = pos;
51+
let rangeStart = '';
52+
WHILE: while (i < glob.length) {
53+
const c = glob.charAt(i);
54+
if ((c === '!' || c === '^') && i === pos + 1) {
55+
negate = true;
56+
i++;
57+
continue;
58+
}
59+
if (c === ']' && sawStart && !escaping) {
60+
endPos = i + 1;
61+
break;
62+
}
63+
sawStart = true;
64+
if (c === '\\') {
65+
if (!escaping) {
66+
escaping = true;
67+
i++;
68+
continue;
69+
}
70+
// escaped \ char, fall through and treat like normal char
71+
}
72+
if (c === '[' && !escaping) {
73+
// either a posix class, a collation equivalent, or just a [
74+
for (const [cls, [unip, u, neg]] of Object.entries(posixClasses)) {
75+
if (glob.startsWith(cls, i)) {
76+
// invalid, [a-[] is fine, but not [a-[:alpha]]
77+
if (rangeStart) {
78+
return ['$.', false, glob.length - pos, true];
79+
}
80+
i += cls.length;
81+
if (neg)
82+
negs.push(unip);
83+
else
84+
ranges.push(unip);
85+
uflag = uflag || u;
86+
continue WHILE;
87+
}
88+
}
89+
}
90+
// now it's just a normal character, effectively
91+
escaping = false;
92+
if (rangeStart) {
93+
// throw this range away if it's not valid, but others
94+
// can still match.
95+
if (c > rangeStart) {
96+
ranges.push(braceEscape(rangeStart) + '-' + braceEscape(c));
97+
}
98+
else if (c === rangeStart) {
99+
ranges.push(braceEscape(c));
100+
}
101+
rangeStart = '';
102+
i++;
103+
continue;
104+
}
105+
// now might be the start of a range.
106+
// can be either c-d or c-] or c<more...>] or c] at this point
107+
if (glob.startsWith('-]', i + 1)) {
108+
ranges.push(braceEscape(c + '-'));
109+
i += 2;
110+
continue;
111+
}
112+
if (glob.startsWith('-', i + 1)) {
113+
rangeStart = c;
114+
i += 2;
115+
continue;
116+
}
117+
// not the start of a range, just a single character
118+
ranges.push(braceEscape(c));
119+
i++;
120+
}
121+
if (endPos < i) {
122+
// didn't see the end of the class, not a valid class,
123+
// but might still be valid as a literal match.
124+
return ['', false, 0, false];
125+
}
126+
// if we got no ranges and no negates, then we have a range that
127+
// cannot possibly match anything, and that poisons the whole glob
128+
if (!ranges.length && !negs.length) {
129+
return ['$.', false, glob.length - pos, true];
130+
}
131+
// if we got one positive range, and it's a single character, then that's
132+
// not actually a magic pattern, it's just that one literal character.
133+
// we should not treat that as "magic", we should just return the literal
134+
// character. [_] is a perfectly valid way to escape glob magic chars.
135+
if (negs.length === 0 &&
136+
ranges.length === 1 &&
137+
/^\\?.$/.test(ranges[0]) &&
138+
!negate) {
139+
const r = ranges[0].length === 2 ? ranges[0].slice(-1) : ranges[0];
140+
return [regexpEscape(r), false, endPos - pos, false];
141+
}
142+
const sranges = '[' + (negate ? '^' : '') + rangesToString(ranges) + ']';
143+
const snegs = '[' + (negate ? '' : '^') + rangesToString(negs) + ']';
144+
const comb = ranges.length && negs.length
145+
? '(' + sranges + '|' + snegs + ')'
146+
: ranges.length
147+
? sranges
148+
: snegs;
149+
return [comb, uflag, endPos - pos, true];
150+
};
151+
exports.parseClass = parseClass;
152+
//# sourceMappingURL=brace-expressions.js.map
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":3,"file":"brace-expressions.js","sourceRoot":"","sources":["../../src/brace-expressions.ts"],"names":[],"mappings":";AAAA,wEAAwE;AACxE,wCAAwC;;;AAExC,8DAA8D;AAC9D,MAAM,YAAY,GAA0D;IAC1E,WAA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,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,cAAc,CAAC,MAAM,CAAC,GAAG,GAAG,CAAA;IACxE,MAAM,KAAK,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,GAAG,GAAG,CAAA;IACpE,MAAM,IAAI,GACR,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM;QAC1B,CAAC,CAAC,GAAG,GAAG,OAAO,GAAG,GAAG,GAAG,KAAK,GAAG,GAAG;QACnC,CAAC,CAAC,MAAM,CAAC,MAAM;YACf,CAAC,CAAC,OAAO;YACT,CAAC,CAAC,KAAK,CAAA;IAEX,OAAO,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,GAAG,EAAE,IAAI,CAAC,CAAA;AAC1C,CAAC,CAAA;AAhIY,QAAA,UAAU,cAgItB"}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { MinimatchOptions } from './index.js';
2+
/**
3+
* Escape all magic characters in a glob pattern.
4+
*
5+
* If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
6+
* option is used, then characters are escaped by wrapping in `[]`, because
7+
* a magic character wrapped in a character class can only be satisfied by
8+
* that exact character. In this mode, `\` is _not_ escaped, because it is
9+
* not interpreted as a magic character, but instead as a path separator.
10+
*/
11+
export declare const escape: (s: string, { windowsPathsNoEscape, }?: Pick<MinimatchOptions, 'windowsPathsNoEscape'>) => string;
12+
//# sourceMappingURL=escape.d.ts.map
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C;;;;;;;;GAQG;AACH,eAAO,MAAM,MAAM,MACd,MAAM,8BAGN,KAAK,gBAAgB,EAAE,sBAAsB,CAAC,WAQlD,CAAA"}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.escape = void 0;
4+
/**
5+
* Escape all magic characters in a glob pattern.
6+
*
7+
* If the {@link windowsPathsNoEscape | GlobOptions.windowsPathsNoEscape}
8+
* option is used, then characters are escaped by wrapping in `[]`, because
9+
* a magic character wrapped in a character class can only be satisfied by
10+
* that exact character. In this mode, `\` is _not_ escaped, because it is
11+
* not interpreted as a magic character, but instead as a path separator.
12+
*/
13+
const escape = (s, { windowsPathsNoEscape = false, } = {}) => {
14+
// don't need to escape +@! because we escape the parens
15+
// that make those magic, and escaping ! as [!] isn't valid,
16+
// because [!]] is a valid glob class meaning not ']'.
17+
return windowsPathsNoEscape
18+
? s.replace(/[?*()[\]]/g, '[$&]')
19+
: s.replace(/[?*()[\]\\]/g, '\\$&');
20+
};
21+
exports.escape = escape;
22+
//# sourceMappingURL=escape.js.map
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":3,"file":"escape.js","sourceRoot":"","sources":["../../src/escape.ts"],"names":[],"mappings":";;;AACA;;;;;;;;GAQG;AACI,MAAM,MAAM,GAAG,CACpB,CAAS,EACT,EACE,oBAAoB,GAAG,KAAK,MACsB,EAAE,EACtD,EAAE;IACF,wDAAwD;IACxD,4DAA4D;IAC5D,sDAAsD;IACtD,OAAO,oBAAoB;QACzB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,CAAC;QACjC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;AACvC,CAAC,CAAA;AAZY,QAAA,MAAM,UAYlB"}

0 commit comments

Comments
 (0)