Files
lucide/packages/lab/scripts/copyIcons.mjs
T
9ecaafbc4d feat(lab): Migrate lab to main repo. (#4521)
* Add directory

* Add lab check script

* Delete duplicated icons

* Fix the lab page

* Adjust paths

* update lockfile

* update lockfile

* fix(lab/planet): replace with guideline-compliant design

* Add install step

* Add second install step

* Adjust lab in site

* try this

* Fix workflow

* Add cspell

* Format code

* Temporary delete icons for copilot review

* Place back lab icons

* Apply suggestions from code review

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Update lock file

* Revert svg changes

* Fix list

* Rename filenames

* Format tsconfig

---------

Co-authored-by: Karsa <contact@karsa.org>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-24 15:05:40 +02:00

26 lines
766 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)) {
try {
unlinkSync(iconsDirectory);
} catch (error) {}
}
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);
}