-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
42 lines (34 loc) · 1.1 KB
/
build.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
const fs = require("fs");
const lineReader = require("line-reader");
const rimraf = require("rimraf");
const PackageName = "materialdesign-js";
const mdiFilePath = require.resolve("@mdi/js/mdi.js");
const buildDir = "./icons";
build = () => {
console.log("----------------------------------");
console.log(`[${PackageName}] Building icons files...`);
if (fs.existsSync(buildDir)) {
console.log(`[${PackageName}] Deleting old icons...`);
rimraf.sync(buildDir);
}
console.log(`[${PackageName}] Generating material design icons files...`);
fs.mkdirSync(buildDir);
var generatedIcons = 0;
lineReader.eachLine(
mdiFilePath,
function (line) {
if (line.substr(0, 2) === "//") return;
line = line.split(" = ");
fileName = line[0].substr(11);
data = "export default " + line[1];
fs.writeFileSync(`${buildDir}/${fileName}.js`, data);
generatedIcons++;
},
function (err) {
if (err) throw err;
console.log(`[${PackageName}] ${generatedIcons} icons generated.`);
console.log("----------------------------------");
}
);
};
build();