forked from rgossiaux/svelte-heroicons
-
Notifications
You must be signed in to change notification settings - Fork 1
/
generate.js
29 lines (24 loc) · 1.22 KB
/
generate.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
import * as fs from "fs/promises";
import { generateFromFolder } from "svg-to-svelte";
const options = { clean: true };
async function generate() {
await generateFromFolder("node_modules/heroicons/20/solid", "src/lib/mini", options);
let index = await fs.readFile("src/lib/mini/index.js", { encoding: "utf-8" });
index = index
.replace(/export { (\w+) }/g, "export { $1 as $1Icon }")
.replace(/from ".\/(\w+)";/g, 'from "./$1/index.js";');
await fs.writeFile("src/lib/mini/index.js", index);
await generateFromFolder("node_modules/heroicons/24/solid", "src/lib/solid", options);
index = await fs.readFile("src/lib/solid/index.js", { encoding: "utf-8" });
index = index
.replace(/export { (\w+) }/g, "export { $1 as $1Icon }")
.replace(/from ".\/(\w+)";/g, 'from "./$1/index.js";');
await fs.writeFile("src/lib/solid/index.js", index);
await generateFromFolder("node_modules/heroicons/24/outline", "src/lib/outline", options);
index = await fs.readFile("src/lib/outline/index.js", { encoding: "utf-8" });
index = index
.replace(/export { (\w+) }/g, "export { $1 as $1Icon }")
.replace(/from ".\/(\w+)";/g, 'from "./$1/index.js";');
await fs.writeFile("src/lib/outline/index.js", index);
}
generate();