mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-16 16:47:43 +01:00
* Make sure all classes are applied for all packages * Add class test to angular component * Adjust lucide-static tests * update snapshot * Fix types
24 lines
731 B
JavaScript
24 lines
731 B
JavaScript
import { writeFile } from 'fs/promises';
|
|
import { existsSync, unlinkSync, mkdirSync } from 'fs';
|
|
|
|
export default async function copyIcons(parsedSvgs, packageDir, license) {
|
|
const iconsDirectory = `${packageDir}/icons`;
|
|
|
|
if (existsSync(iconsDirectory)) {
|
|
unlinkSync(iconsDirectory);
|
|
}
|
|
|
|
if (!existsSync(iconsDirectory)) {
|
|
mkdirSync(iconsDirectory);
|
|
}
|
|
// eslint-disable-next-line arrow-body-style
|
|
const writeIconPromises = parsedSvgs.map(({ name, contents }) => {
|
|
let content = `<!-- ${license} -->\n${contents}`;
|
|
content = content.replace('<svg', `<svg\n class="lucide lucide-${name}"`);
|
|
|
|
return writeFile(`${iconsDirectory}/${name}.svg`, content);
|
|
});
|
|
|
|
await Promise.all(writeIconPromises);
|
|
}
|