-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.mjs
29 lines (23 loc) · 967 Bytes
/
build.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 pascalcase from "pascalcase";
const weightDirs = fs.readdirSync("phosphor-icons/SVGs Flat");
const heading = `---
import type { HTMLAttributes } from "astro/types";
export type Props = HTMLAttributes<'svg'>
---
`;
weightDirs.forEach((weighDir) => {
const files = fs.readdirSync(`./phosphor-icons/SVGs Flat/${weighDir}`);
console.log(files.length);
files.forEach((file) => {
const content = fs.readFileSync(`./phosphor-icons/SVGs Flat/${weighDir}/${file}`, "utf-8");
const next = content
.replace("<svg ", "<svg {...Astro.props} ")
.replace("#000", "currentColor");
const [name] = file.split(".");
fs.writeFileSync(`./${pascalcase(name)}.astro`, heading + next);
});
});
const phosphorLicense = fs.readFileSync("./phosphor-icons/LICENSE", "utf-8");
const libraryLicense = fs.readFileSync("./LIBRARY_LICENSE", "utf-8");
fs.writeFileSync("./LICENSE", phosphorLicense + "\n---\n\n" + libraryLicense);