Files
lucide/scripts/building/generateExportsFile.mjs
Louis Bailleau 55ae908018 Update all packages dependencies in project root (#863)
* Update `svgo` and `svgson` version and fix some tests

* Update eslint-related packages and fix all linter errors

* Update all rollup-related packages version

* Update all rollup-related packages (part 2)

* Update the rest of package which need to be updated

* Fix unwanted comment

* Fix unwanted comment (again)
2022-11-07 22:29:19 +01:00

27 lines
840 B
JavaScript

import path from 'path';
import { toPascalCase, resetFile, appendFile } from '../helpers.mjs';
export default (inputEntry, outputDirectory, iconNodes, iconFileExtention = '') => {
const fileName = path.basename(inputEntry);
// Reset file
resetFile(fileName, outputDirectory);
const icons = Object.keys(iconNodes);
const fileExtention =
iconFileExtention === '.ts' || iconFileExtention === '.js' ? '' : iconFileExtention;
// Generate Import for Icon VNodes
icons.forEach((iconName) => {
const componentName = toPascalCase(iconName);
const importString = `export { default as ${componentName} } from './${iconName}${fileExtention}';\n`;
appendFile(importString, fileName, outputDirectory);
});
appendFile('\n', fileName, outputDirectory);
console.log(`Successfully generated ${fileName} file`);
};