@@ -6,12 +6,9 @@ const axios = require('axios')
66const iconURL = 'https://fonts.google.com/metadata/icons'
77
88function setup ( ) {
9- // Create components folder
10- fs . mkdirSync ( path . join ( __dirname , 'src' , 'components' ) )
11-
129 // Create types file
1310 fs . writeFileSync (
14- path . join ( __dirname , 'src' , 'components' , ' types.ts') ,
11+ path . join ( __dirname , 'src' , 'types.ts' ) ,
1512 'import React from "react" \nexport type IconProps = React.SVGProps<SVGSVGElement>'
1613 )
1714}
@@ -45,7 +42,7 @@ function componentTemplate(name, svg) {
4542 component += "import { IconProps } from './types'\n\n"
4643 component += `const ${ name } : React.FC<IconProps> = (props) => (`
4744 component += svg + ')\n\n'
48- component += `export { ${ name } }`
45+ component += `export { ${ name } as default }`
4946
5047 return component
5148}
@@ -61,34 +58,12 @@ function generateComponent(icon) {
6158 const svg = await getSVGFile ( c . name , c . version )
6259
6360 fs . writeFileSync (
64- path . join ( __dirname , 'src' , 'components' , `${ name } .tsx` ) ,
61+ path . join ( __dirname , 'src' , `${ name } .tsx` ) ,
6562 componentTemplate ( name , svg )
6663 )
6764 } )
6865}
6966
70- /**
71- * Generate index tsx file for easy import
72- *
73- * @param icons - Array of icons
74- */
75- function generateIndex ( icons ) {
76- let imports = ''
77- let exports = 'export {\n'
78-
79- icons . forEach ( ( icon ) => {
80- const name = formatName ( icon . name )
81- imports += `import { ${ name } } from './components/${ name } '\n`
82- exports += ` ${ name } ,\n`
83- } )
84- exports += '}'
85-
86- fs . writeFileSync (
87- path . join ( __dirname , 'src' , 'index.ts' ) ,
88- imports + '\n' + exports
89- )
90- }
91-
9267/**
9368 * Get SVG data form google static fonts api
9469 *
@@ -105,6 +80,9 @@ async function getSVGFile(icon, version) {
10580 . replace ( 'height="24"' , '' )
10681 . replace ( 'width="24"' , '{...props}' )
10782 . replace ( / c l a s s / g, 'className' )
83+ . replace ( / e n a b l e - b a c k g r o u n d / g, 'enableBackground' )
84+ . replace ( / c l i p - r u l e / g, 'clipRule' )
85+ . replace ( / f i l l - r u l e / g, 'fillRule' )
10886}
10987
11088/**
@@ -124,5 +102,4 @@ async function getSVGFile(icon, version) {
124102
125103 // Generate icon components and Index
126104 await generateComponent ( icons . icons )
127- await generateIndex ( icons . icons )
128105} ) ( )
0 commit comments