-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.mjs
29 lines (26 loc) · 799 Bytes
/
test.mjs
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
import fs from "fs";
import path from "path";
import $ from "cheerio";
const directories = ["src/Icons", "src/Icons/icon"];
let errors = 0;
directories.forEach((dir) =>
fs.readdirSync(dir).forEach((file) => {
const filePath = path.join(dir, file);
if (fs.statSync(filePath).isFile() && file !== "index.ts") {
const width = $.load(fs.readFileSync(filePath))("svg").attr("width");
const height = $.load(fs.readFileSync(filePath))("svg").attr("height");
if (!width && !height) {
console.error(
`Error: \`${filePath}\` has a width of \x1b[31m\`${width}\`\x1b[0m`,
`and a height of \x1b[31m\`${height}\`\x1b[0m`,
);
errors++;
}
}
}),
);
if (errors > 0) {
process.exit(1);
} else {
console.log("Tests passed!");
}