-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomate.js
More file actions
40 lines (35 loc) · 976 Bytes
/
automate.js
File metadata and controls
40 lines (35 loc) · 976 Bytes
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
const fs = require("fs");
const path = require("path");
const parser = require("./jsonParser");
async function parse(file) {
try {
const result = await parser(file);
console.info("result", result);
} catch (e) {
console.error(e?.message || e);
}
console.log(process.exitCode);
}
async function main() {
const testFolder = "./tests/";
//get folders
const folders = fs
.readdirSync(testFolder, { withFileTypes: true })
.filter((item) => item.isDirectory())
.map((item) => item.name);
for (let folder of folders) {
const folderPath = `${testFolder}${folder}`;
//get json files in each folder
const files = fs
.readdirSync(folderPath, { withFileTypes: true })
.filter(
(item) => !item.isDirectory() && path.extname(item.name) === ".json"
)
.map((item) => item.name);
// parse each file
for (let file of files) {
await parse(`${folderPath}/${file}`);
}
}
}
main().then();