mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-08-29 09:28:23 +02:00
* chore(lab): Adjust build scripts * add check workflow * Potential fix for pull request finding 'CodeQL / Workflow does not contain permissions' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * update gitignore --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
29 lines
814 B
TypeScript
29 lines
814 B
TypeScript
import { writeFile } from 'fs/promises';
|
|
import { existsSync, unlinkSync, mkdirSync } from 'fs';
|
|
import { type SVGFile } from './readSvgs.mts';
|
|
|
|
export default async function copyIcons(
|
|
parsedSvgs: SVGFile[],
|
|
packageDir: string,
|
|
license: string,
|
|
) {
|
|
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);
|
|
}
|