import { readFileSync, readdirSync } from "fs"; import { extname } from "path"; function findFiles(dir: string): string[] { const res: string[] = []; const dirs = readdirSync(dir, { withFileTypes: true }); for (const d of dirs) { if (d.isDirectory()) { res.push(...findFiles(dir + d.name + "/")); } else { if (extname(d.name) == ".svg") { const svg = readFileSync(dir + d.name) .toString() .replace(/(\r)|(\n)/g, "") .replace(/", ""); res.push(svg); } } } return res; } export function createSvg(html: string) { const res = findFiles("./src/modules/"); return html.replace( "
", ` ` ); }