-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate-Docs--1.0.ts
52 lines (46 loc) · 1.08 KB
/
validate-Docs--1.0.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import {
writeFile,
} from 'fs/promises';
import {
ValidationError,
} from './lib/DocsTsGenerator';
import {
NoMatchError,
} from './lib/Exceptions';
import {
docs,
} from './lib/helpers';
import {
setup_PerformanceObserver,
} from './setup_PerformanceObserver';
import {
__dirname_from_meta,
} from './lib/__dirname';
import {
versions,
} from './version-configs';
const __dirname = __dirname_from_meta(import.meta);
setup_PerformanceObserver();
const version = 'version_1_0_0_4';
const sub_path = versions.version_1_0_0_4;
try {
await docs.get(version);
} catch (err) {
if (err instanceof ValidationError) {
for (const error of err.errors) {
process.stdout.write(JSON.stringify(error, null, '\t') + '\n');
}
} else if (err instanceof NoMatchError) {
const {property, ...rest} = err as NoMatchError;
delete rest.stack;
process.stdout.write(JSON.stringify(property, null, '\t') + '\n');
console.error(rest);
} else {
throw err;
}
await writeFile(
`${__dirname}/failed-to-compile.${sub_path}.json`,
`${JSON.stringify(err, null, '\t')}\n`,
);
console.error(err.stack);
}