-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvalidate.ts
43 lines (35 loc) · 1.01 KB
/
validate.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
import * as path from "path";
import * as fs from "fs-extra";
import {XMLValidator} from "fast-xml-parser";
import * as utils from "./utils";
// Validate all the xml files in the assets folder.
(async () => {
const label = "XML"
console.time(label);
const basePath = path.resolve(__dirname, "../");
const assetsPath = path.join(basePath, "./assets/");
let allValid = true;
utils.allFilesInDirectory(assetsPath).filter(filepath => {
return path.extname(filepath) === ".xml";
}).forEach(async filepath => {
try {
console.timeLog(label, filepath);
const content = await fs.promises.readFile(filepath, {
"encoding": "utf-8"
});
const result = XMLValidator.validate(content);
if (result !== true) {
allValid = false;
console.error(filepath);
console.error(result.err);
}
}
catch(err) {
allValid = false;
console.error(filepath);
console.error(err);
}
});
console.timeEnd(label);
return allValid;
})()