-
Notifications
You must be signed in to change notification settings - Fork 0
/
check.ts
48 lines (43 loc) · 1.11 KB
/
check.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
import fs from 'fs';
import { exit } from 'process';
interface Env {
url?: string;
key?: {
recognition?: string;
detection?: string;
verify?: string;
};
}
const envFile = 'test/env.json';
if (!fs.existsSync(envFile)) {
console.error('No environment file found for test!');
exit(1);
}
try {
const data = fs.readFileSync(envFile, 'utf-8');
const env = JSON.parse(data) as Env;
if (!env.url?.trim()) {
console.error('"url" is empty in the environment file for test!');
exit(1);
}
if (!env.key) {
console.error('"key" is empty in the environment file for test!');
exit(1);
} else {
if (!env.key.recognition?.trim()) {
console.error('"key.recognition" is empty in the environment file for test!');
exit(1);
}
if (!env.key.detection?.trim()) {
console.error('"key.detection" is empty in the environment file for test!');
exit(1);
}
if (!env.key.verify?.trim()) {
console.error('"key.verify" is empty in the environment file for test!');
exit(1);
}
}
} catch {
console.error('Environment file for test is wrong!');
exit(1);
}