-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
check_examples.ts
35 lines (31 loc) 路 965 Bytes
/
check_examples.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expandGlobSync } from "https://deno.land/std@0.167.0/fs/expand_glob.ts";
const MAX_PARALLEL = Number(Deno.env.get("MAX_PARALLEL")) || 8;
const files = [...expandGlobSync("./examples/**/**.ts")];
const errors: Array<Error> = [];
await Promise.all(
files.splice(0, MAX_PARALLEL).map((file) => checkExample(file.path)),
);
if (errors.length) {
errors.forEach((error) => console.error(error));
console.error("%s examples have errors.", errors.length);
Deno.exit(1);
}
async function checkExample(file: string): Promise<void> {
console.log("Type check example:", file);
const output = await Deno.spawn("deno", {
args: ["check", "--unstable", file],
});
if (!output.success) {
errors.push(
new Error(
`Type checking failed for ${file} \n${
new TextDecoder().decode(output.stderr)
}`,
),
);
}
const nextFile = files.shift();
if (nextFile) {
return checkExample(nextFile.path);
}
}