mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-18 14:38:24 +00:00
37 lines
1.0 KiB
JavaScript
37 lines
1.0 KiB
JavaScript
import path from 'path';
|
|
|
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
import { toPascalCase, toCamelCase, resetFile, appendFile } from '@lucide/helpers';
|
|
|
|
export default function generateIndexFile (
|
|
inputEntry,
|
|
outputDirectory,
|
|
iconNodes,
|
|
exportModuleNameCasing,
|
|
iconFileExtension = '',
|
|
) {
|
|
const fileName = path.basename(inputEntry);
|
|
|
|
// Reset file
|
|
resetFile(fileName, outputDirectory);
|
|
|
|
const icons = Object.keys(iconNodes);
|
|
|
|
// Generate Import for Icon VNodes
|
|
icons.forEach((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`;
|
|
appendFile(importString, fileName, outputDirectory);
|
|
});
|
|
|
|
appendFile('\n', fileName, outputDirectory);
|
|
|
|
console.log(`Successfully generated ${fileName} file`);
|
|
};
|