Skip to content

Commit 8a9959e

Browse files
authored
fix: inline @types/glob (#336)
1 parent b773063 commit 8a9959e

File tree

4 files changed

+174
-14
lines changed

4 files changed

+174
-14
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"prepare": "tsc"
3535
},
3636
"dependencies": {
37-
"@types/glob": "^7.1.0",
3837
"commander": "^5.0.0",
3938
"glob": "^7.1.6",
4039
"minimatch": "^3.0.4"

src/types/glob.d.ts

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
/**
2+
* TODO(erikian): remove this file once we upgrade to the latest `glob` version.
3+
* https://github.com/electron/asar/pull/332#issuecomment-2435407933
4+
*/
5+
6+
declare module 'glob' {
7+
export function glob(
8+
pattern: string,
9+
options: IGlobOptions,
10+
cb: (err: Error | null, matches: string[]) => void,
11+
): unknown;
12+
13+
export interface IOptions extends IGlobOptions {}
14+
}
15+
16+
interface IMinimatchOptions {
17+
/**
18+
* Dump a ton of stuff to stderr.
19+
*
20+
* @default false
21+
*/
22+
debug?: boolean | undefined;
23+
24+
/**
25+
* Do not expand `{a,b}` and `{1..3}` brace sets.
26+
*
27+
* @default false
28+
*/
29+
nobrace?: boolean | undefined;
30+
31+
/**
32+
* Disable `**` matching against multiple folder names.
33+
*
34+
* @default false
35+
*/
36+
noglobstar?: boolean | undefined;
37+
38+
/**
39+
* Allow patterns to match filenames starting with a period,
40+
* even if the pattern does not explicitly have a period in that spot.
41+
*
42+
* Note that by default, `'a/**' + '/b'` will **not** match `a/.d/b`, unless `dot` is set.
43+
*
44+
* @default false
45+
*/
46+
dot?: boolean | undefined;
47+
48+
/**
49+
* Disable "extglob" style patterns like `+(a|b)`.
50+
*
51+
* @default false
52+
*/
53+
noext?: boolean | undefined;
54+
55+
/**
56+
* Perform a case-insensitive match.
57+
*
58+
* @default false
59+
*/
60+
nocase?: boolean | undefined;
61+
62+
/**
63+
* When a match is not found by `minimatch.match`,
64+
* return a list containing the pattern itself if this option is set.
65+
* Otherwise, an empty list is returned if there are no matches.
66+
*
67+
* @default false
68+
*/
69+
nonull?: boolean | undefined;
70+
71+
/**
72+
* If set, then patterns without slashes will be matched
73+
* against the basename of the path if it contains slashes. For example,
74+
* `a?b` would match the path `/xyz/123/acb`, but not `/xyz/acb/123`.
75+
*
76+
* @default false
77+
*/
78+
matchBase?: boolean | undefined;
79+
80+
/**
81+
* Suppress the behavior of treating `#` at the start of a pattern as a comment.
82+
*
83+
* @default false
84+
*/
85+
nocomment?: boolean | undefined;
86+
87+
/**
88+
* Suppress the behavior of treating a leading `!` character as negation.
89+
*
90+
* @default false
91+
*/
92+
nonegate?: boolean | undefined;
93+
94+
/**
95+
* Returns from negate expressions the same as if they were not negated.
96+
* (Ie, true on a hit, false on a miss.)
97+
*
98+
* @default false
99+
*/
100+
flipNegate?: boolean | undefined;
101+
102+
/**
103+
* Compare a partial path to a pattern. As long as the parts of the path that
104+
* are present are not contradicted by the pattern, it will be treated as a
105+
* match. This is useful in applications where you're walking through a
106+
* folder structure, and don't yet have the full path, but want to ensure that
107+
* you do not walk down paths that can never be a match.
108+
*
109+
* @default false
110+
*
111+
* @example
112+
* import minimatch = require("minimatch");
113+
*
114+
* minimatch('/a/b', '/a/*' + '/c/d', { partial: true }) // true, might be /a/b/c/d
115+
* minimatch('/a/b', '/**' + '/d', { partial: true }) // true, might be /a/b/.../d
116+
* minimatch('/x/y/z', '/a/**' + '/z', { partial: true }) // false, because x !== a
117+
*/
118+
partial?: boolean;
119+
120+
/**
121+
* Use `\\` as a path separator _only_, and _never_ as an escape
122+
* character. If set, all `\\` characters are replaced with `/` in
123+
* the pattern. Note that this makes it **impossible** to match
124+
* against paths containing literal glob pattern characters, but
125+
* allows matching with patterns constructed using `path.join()` and
126+
* `path.resolve()` on Windows platforms, mimicking the (buggy!)
127+
* behavior of earlier versions on Windows. Please use with
128+
* caution, and be mindful of the caveat about Windows paths
129+
*
130+
* For legacy reasons, this is also set if
131+
* `options.allowWindowsEscape` is set to the exact value `false`.
132+
*
133+
* @default false
134+
*/
135+
windowsPathsNoEscape?: boolean;
136+
}
137+
138+
export interface IGlobOptions extends IMinimatchOptions {
139+
cwd?: string | undefined;
140+
root?: string | undefined;
141+
dot?: boolean | undefined;
142+
nomount?: boolean | undefined;
143+
mark?: boolean | undefined;
144+
nosort?: boolean | undefined;
145+
stat?: boolean | undefined;
146+
silent?: boolean | undefined;
147+
strict?: boolean | undefined;
148+
cache?: { [path: string]: boolean | 'DIR' | 'FILE' | ReadonlyArray<string> } | undefined;
149+
statCache?: { [path: string]: false | { isDirectory(): boolean } | undefined } | undefined;
150+
symlinks?: { [path: string]: boolean | undefined } | undefined;
151+
realpathCache?: { [path: string]: string } | undefined;
152+
sync?: boolean | undefined;
153+
nounique?: boolean | undefined;
154+
nonull?: boolean | undefined;
155+
debug?: boolean | undefined;
156+
nobrace?: boolean | undefined;
157+
noglobstar?: boolean | undefined;
158+
noext?: boolean | undefined;
159+
nocase?: boolean | undefined;
160+
matchBase?: any;
161+
nodir?: boolean | undefined;
162+
ignore?: string | ReadonlyArray<string> | undefined;
163+
follow?: boolean | undefined;
164+
realpath?: boolean | undefined;
165+
nonegate?: boolean | undefined;
166+
nocomment?: boolean | undefined;
167+
absolute?: boolean | undefined;
168+
allowWindowsEscape?: boolean | undefined;
169+
fs?: typeof import('fs');
170+
}

tsconfig.json

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"types": [
1212
"node"
1313
],
14+
"typeRoots": [
15+
"node_modules/@types",
16+
"src/types"
17+
],
1418
"allowSyntheticDefaultImports": true,
1519
"moduleResolution": "node",
1620
"declaration": true,

yarn.lock

-13
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@
3939
"@types/node" "*"
4040
"@types/responselike" "^1.0.0"
4141

42-
"@types/glob@^7.1.0":
43-
version "7.2.0"
44-
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
45-
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
46-
dependencies:
47-
"@types/minimatch" "*"
48-
"@types/node" "*"
49-
5042
"@types/http-cache-semantics@*":
5143
version "4.0.1"
5244
resolved "https://registry.yarnpkg.com/@types/http-cache-semantics/-/http-cache-semantics-4.0.1.tgz#0ea7b61496902b95890dc4c3a116b60cb8dae812"
@@ -59,11 +51,6 @@
5951
dependencies:
6052
"@types/node" "*"
6153

62-
"@types/minimatch@*":
63-
version "5.1.2"
64-
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-5.1.2.tgz#07508b45797cb81ec3f273011b054cd0755eddca"
65-
integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==
66-
6754
"@types/minimatch@^3.0.5":
6855
version "3.0.5"
6956
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"

0 commit comments

Comments
 (0)