mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-15 14:08:49 +00:00
New setup for new NPM package
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import prettier from 'prettier';
|
||||
import { generateComponentName } from './helpers';
|
||||
|
||||
export default function(iconVNodesObject) {
|
||||
|
||||
const icons = Object.keys(iconVNodesObject);
|
||||
|
||||
icons.forEach(icon => {
|
||||
const location = path.join(process.cwd(), "src/icons", `${icon}.js`);
|
||||
const ComponentName = generateComponentName(icon);
|
||||
|
||||
const VNode = JSON.stringify(iconVNodesObject[icon]);
|
||||
|
||||
const element = `
|
||||
export default [${VNode}]
|
||||
`
|
||||
|
||||
fs.writeFileSync(
|
||||
location,
|
||||
prettier.format(element, { parser: "babel" }),
|
||||
"utf-8"
|
||||
);
|
||||
|
||||
console.log("Successfully built", ComponentName);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import prettier from 'prettier';
|
||||
|
||||
import { generateComponentName } from './helpers';
|
||||
|
||||
const FILE_NAME = "react.js";
|
||||
|
||||
const resetFile = fs.writeFileSync(path.join(process.cwd(), FILE_NAME), "", "utf-8");
|
||||
const writeFile = (content) => fs.appendFileSync(
|
||||
path.join(process.cwd(), FILE_NAME),
|
||||
content,
|
||||
"utf-8"
|
||||
);
|
||||
|
||||
export default function(iconVNodesObject) {
|
||||
|
||||
writeFile();
|
||||
writeFile(`import getReactComponent from './src/getReactComponent';\n`);
|
||||
|
||||
// const componentName = generateComponentName(icon);
|
||||
const icons = Object.keys(iconVNodesObject);
|
||||
|
||||
// icons.forEach(iconName => {
|
||||
// const constantString = `const ${componentName} = getReactComponent();\n`;
|
||||
// const exportString = `export ${componentName};\n`;
|
||||
|
||||
|
||||
// });
|
||||
|
||||
// icons.forEach(iconName => {
|
||||
// const constantString = `const ${componentName} = getReactComponent();\n`;
|
||||
// const exportString = `export ${componentName};\n`;
|
||||
|
||||
|
||||
// });
|
||||
|
||||
const exportStringNames = icons.map(iconName => generateComponentName(iconName)).join(",\n");
|
||||
const exportString = `export { ${exportStringNames} };\n`;
|
||||
|
||||
writeFile(exportString);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import upperCamelCase from 'upperCamelCase';
|
||||
|
||||
/**
|
||||
* Generates a componentName of a String.
|
||||
*
|
||||
* @param {string} iconName
|
||||
*/
|
||||
export const generateComponentName = (iconName) => iconName === "github" ? "GitHub" : upperCamelCase(iconName);
|
||||
Reference in New Issue
Block a user