-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-build-icons.js
36 lines (33 loc) · 915 Bytes
/
post-build-icons.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
const fs = require('fs/promises');
const path = require('path');
(async () => {
const iconsPath = path.join('src', 'icons');
const icons = await fs.readdir(iconsPath, {
encoding: 'utf8'
});
await Promise.all(
icons.map(async (file) => {
const iconPath = path.join(iconsPath, file);
const content = await fs.readFile(iconPath, {
encoding: 'utf8'
});
await fs.writeFile(
iconPath,
content
.replace(/'#000'/gm, "'currentColor'")
.replace(/"#000"/gm, '"currentColor"')
.replace(
/strokeWidth={([0-9]+)}/gm,
'strokeWidth={strokeWidth === undefined ? $1 : strokeWidth}'
)
.replace(
/strokeWidth: ([0-9]+)/gm,
'strokeWidth: strokeWidth === undefined ? $1 : strokeWidth'
),
{
encoding: 'utf8'
}
);
})
);
})();