-
Notifications
You must be signed in to change notification settings - Fork 9
/
generate.js
39 lines (35 loc) · 992 Bytes
/
generate.js
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
const fs = require("fs");
const config = require("./config/config.json");
const { init, load } = require("./parser/node");
init(config, "mirrorz-d-extension"); // global.fetch, global.DOMParser, global.Timeout, global.timeout
const parsers = require("./parser/parsers");
const custom = require("./custom");
const LIST = {
...config.d_mirrors,
...Object.fromEntries(
config.d_parser.map((e) => [
e,
async () => {
if (parsers[e]) {
return custom[e](await load(parsers[e]));
} else {
// try load mirrorz file from config.mirrors
return custom[e](await load(config.mirrors[e]));
}
},
])
),
};
async function main() {
fs.mkdirSync("./dist/", { recursive: true });
for (site in LIST) {
const mirrorzd = await load(LIST[site]);
if (mirrorzd !== null)
fs.writeFileSync(
"./dist/" + site + ".d.json",
JSON.stringify(mirrorzd, null, 2)
);
}
process.exit(0);
}
main();