-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile_datafiles.js
executable file
·61 lines (49 loc) · 1.6 KB
/
compile_datafiles.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const fs = require("fs");
const path = require("path");
const dataFolderPath = "./case-reports-data";
const outputFolderPath = "./case-reports";
const allCases = [];
function updateAllCases() {
let ignoredCaseReports = [];
const ignoredCaseReportsPath = path.join(
dataFolderPath,
"ignored-case-reports.json"
);
if (fs.existsSync(ignoredCaseReportsPath)) {
const ignoredCaseReportsContent = fs.readFileSync(
ignoredCaseReportsPath,
"utf8"
);
try {
ignoredCaseReports = JSON.parse(ignoredCaseReportsContent);
} catch (error) {
console.error(
`Error parsing visibles.json in ${dataFolderPath}: ${error.message}`
);
}
}
fs.readdirSync(dataFolderPath).forEach((caseFolder) => {
const caseFolderPath = path.join(dataFolderPath, caseFolder);
const metadataPath = path.join(caseFolderPath, "metadata.json");
if (fs.existsSync(metadataPath)) {
const metadataContent = fs.readFileSync(metadataPath, "utf8");
try {
let metadata = JSON.parse(metadataContent);
if (metadata.length > 0) {
metadata[0].visible = !ignoredCaseReports.includes(metadata[0].pair);
}
allCases.push(...metadata);
} catch (error) {
console.error(
`Error parsing metadata.json in ${caseFolderPath}: ${error.message}`
);
}
}
});
const allCasesPath = path.join(outputFolderPath, "datafiles.json");
fs.writeFileSync(allCasesPath, JSON.stringify(allCases, null, 2));
console.log(
`datafiles.json has been updated with ${allCases.length} entries.`
);
}
updateAllCases();