import { statSync } from 'node:fs'; import fs from 'node:fs/promises'; import path from 'node:path'; export async function readSvg(filename: string) { return fs.readFile(filename, 'utf-8'); } export async function readSvgCategories(dirname: string) { const dirs = await fs.readdir(dirname); return dirs.filter(dirOrFile => { const stats = statSync(path.resolve(dirname, dirOrFile)); return stats.isDirectory(); }); } export async function getSvgFiles(dirname: string) { const files = await fs.readdir(dirname); return files .filter(file => path.extname(file) === '.svg') .map(file => path.resolve(dirname, file)); } export async function writeFile(filename: string, content: string) { await fs.writeFile(filename, content, 'utf-8'); } export function kebabToCamel(keywords: string) { const [first, ...rest] = keywords.split('-'); return ( first + rest.map(word => word.charAt(0).toUpperCase() + word.slice(1)).join('') ); } export function kebabToPascal(keywords: string) { const camel = kebabToCamel(keywords); return camel.charAt(0).toUpperCase() + camel.slice(1); }