mirror of
https://github.com/lucide-icons/lucide.git
synced 2025-12-15 21:37:43 +01:00
* Adjust typescript types * adjust types * fix types in all helper files * Fix types * Migrate js files to ts files * Refactor to TS files * Rename extentions * Adjust imports * Fix builds * Update lockfile * Fix last typescript migration * Fix entry path @lucide/outline-svg * Fix types * add checkout step * format files * Format files
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import path from 'path';
|
|
|
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import { toPascalCase, toCamelCase, resetFile, appendFile } from '@lucide/helpers';
|
|
import type { IconNode } from '../types.ts';
|
|
|
|
export default async function generateExportFile(
|
|
inputEntry: string,
|
|
outputDirectory: string,
|
|
iconNodes: IconNode,
|
|
exportModuleNameCasing: 'camel' | 'pascal',
|
|
iconFileExtension = '',
|
|
) {
|
|
const fileName = path.basename(inputEntry);
|
|
|
|
// Reset file
|
|
await resetFile(fileName, outputDirectory);
|
|
|
|
const icons = Object.keys(iconNodes);
|
|
|
|
// Generate Import for Icon VNodes
|
|
const iconImportNodesPromises = icons.map(async (iconName) => {
|
|
let componentName;
|
|
|
|
if (exportModuleNameCasing === 'camel') {
|
|
componentName = toCamelCase(iconName);
|
|
} else if (exportModuleNameCasing === 'pascal') {
|
|
componentName = toPascalCase(iconName);
|
|
}
|
|
const importString = `export { default as ${componentName} } from './${iconName}${iconFileExtension}';\n`;
|
|
return appendFile(importString, fileName, outputDirectory);
|
|
});
|
|
|
|
await Promise.all(iconImportNodesPromises);
|
|
|
|
await appendFile('\n', fileName, outputDirectory);
|
|
|
|
console.log(`Successfully generated ${fileName} file`);
|
|
}
|