Skip to content

Commit 565ba74

Browse files
committed
fix: inline @types/glob
1 parent b773063 commit 565ba74

File tree

5 files changed

+175
-16
lines changed

5 files changed

+175
-16
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/crawlfs.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { promisify } from 'util';
2-
import { glob as _glob, IOptions } from 'glob';
2+
import { glob as _glob } from 'glob';
33

44
import fs from './wrapped-fs';
55
import { Stats } from 'fs';
6+
import { IGlobOptions } from './types/glob';
67

78
const glob = promisify(_glob);
89

@@ -27,7 +28,7 @@ export async function determineFileType(filename: string): Promise<CrawledFileTy
2728
return null;
2829
}
2930

30-
export async function crawl(dir: string, options: IOptions) {
31+
export async function crawl(dir: string, options: IGlobOptions) {
3132
const metadata: Record<string, CrawledFileType> = {};
3233
const crawled = await glob(dir, options);
3334
const results = await Promise.all(

src/types/glob.d.ts

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

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)