mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-08-29 09:28:23 +02:00
* 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>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import fs from 'fs';
|
|
import path from 'path';
|
|
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
|
|
|
|
const currentDir = process.cwd();
|
|
const ICONS_DIR = path.resolve(currentDir, '../lab');
|
|
const iconJsonFiles = await readSvgDirectory(ICONS_DIR, '.json');
|
|
|
|
const labDirectory = path.resolve(currentDir, '.vitepress/data/lab');
|
|
const location = path.resolve(currentDir, labDirectory, 'iconMetaData.ts');
|
|
|
|
if (fs.existsSync(location)) {
|
|
fs.unlinkSync(location);
|
|
}
|
|
|
|
if (!fs.existsSync(labDirectory)) {
|
|
fs.mkdirSync(labDirectory);
|
|
}
|
|
|
|
const iconMetaIndexFileImports = [];
|
|
const iconMetaIndexFileExports = [];
|
|
|
|
iconJsonFiles.forEach((iconJsonFile) => {
|
|
const iconName = path.basename(iconJsonFile, '.json');
|
|
|
|
iconMetaIndexFileImports.push(
|
|
`import ${toCamelCase(iconName)}Metadata from '../../../../lab/${iconName}.json';`,
|
|
);
|
|
iconMetaIndexFileExports.push(` '${iconName}': ${toCamelCase(iconName)}Metadata,`);
|
|
});
|
|
|
|
try {
|
|
await fs.promises.writeFile(
|
|
location,
|
|
`\
|
|
${iconMetaIndexFileImports.join('\n')}
|
|
|
|
|
|
export default {
|
|
${iconMetaIndexFileExports.join('\n')}
|
|
}
|
|
`,
|
|
'utf-8',
|
|
);
|
|
|
|
console.log('Successfully write icon json file index');
|
|
} catch (error) {
|
|
throw new Error(`Something went wrong generating icon json file index file,\n ${error}`);
|
|
}
|