-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.js
33 lines (28 loc) · 870 Bytes
/
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
const fs = require('fs');
function toDist(old) {
return old.replace(/^\.\/src\//, './dist/');
}
function walk(dir, fn) {
fs.readdirSync(dir).forEach(file => {
const filePath = `${dir}/${file}`;
const stat = fs.statSync(filePath);
if (stat && stat.isDirectory()) {
fs.mkdirSync(toDist(filePath));
walk(filePath, fn);
} else {
fn(filePath);
}
});
}
function build(file) {
const data = fs.readFileSync(file, 'utf8').toString();
const newData = data
.replace(/(<svg .*width=")(36)(".+height=")(36)/gm, '$11em$31em')
.replace(/(class="[^"]+")/g, 'fill="currentColor"');
const newFile = toDist(file).replace('-line.svg', '-outline.svg');
console.log(`${file} -> ${newFile}`);
fs.writeFileSync(newFile, newData, 'utf8');
}
console.log('Building icons...');
walk('./src', build);
console.log('Building done.');