mirror of
				https://github.com/Mibew/simple-icons.git
				synced 2025-10-30 10:05:52 +03:00 
			
		
		
		
	Build icons in order (#7852)
This commit is contained in:
		
							parent
							
								
									d5444f6995
								
							
						
					
					
						commit
						fdc707bf81
					
				| @ -81,31 +81,29 @@ const build = async () => { | ||||
|   }; | ||||
| 
 | ||||
|   // 'main'
 | ||||
|   const iconsBarrelMjs = []; | ||||
|   const iconsBarrelJs = []; | ||||
|   const iconsBarrelDts = []; | ||||
|   const buildIcons = []; | ||||
| 
 | ||||
|   await Promise.all( | ||||
|   const buildIcons = await Promise.all( | ||||
|     icons.map(async (icon) => { | ||||
|       const filename = getIconSlug(icon); | ||||
|       const svgFilepath = path.resolve(iconsDir, `${filename}.svg`); | ||||
|       icon.svg = (await fs.readFile(svgFilepath, UTF8)).replace(/\r?\n/, ''); | ||||
|       icon.path = svgToPath(icon.svg); | ||||
|       icon.slug = filename; | ||||
|       buildIcons.push(icon); | ||||
| 
 | ||||
|       const iconObject = iconToObject(icon); | ||||
| 
 | ||||
|       const iconExportName = slugToVariableName(icon.slug); | ||||
| 
 | ||||
|       // add object to the barrel file
 | ||||
|       iconsBarrelJs.push(`${iconExportName}:${iconObject},`); | ||||
|       iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`); | ||||
|       iconsBarrelDts.push(`export const ${iconExportName}:I;`); | ||||
|       return { icon, iconObject, iconExportName }; | ||||
|     }), | ||||
|   ); | ||||
| 
 | ||||
|   const iconsBarrelDts = []; | ||||
|   const iconsBarrelJs = []; | ||||
|   const iconsBarrelMjs = []; | ||||
| 
 | ||||
|   buildIcons.forEach(({ icon, iconObject, iconExportName }) => { | ||||
|     iconsBarrelDts.push(`export const ${iconExportName}:I;`); | ||||
|     iconsBarrelJs.push(`${iconExportName}:${iconObject},`); | ||||
|     iconsBarrelMjs.push(`export const ${iconExportName}=${iconObject}`); | ||||
|   }); | ||||
| 
 | ||||
|   // constants used in templates to reduce package size
 | ||||
|   const constantsString = `const a='<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>',b='</title><path d="',c='"/></svg>';`; | ||||
| 
 | ||||
| @ -113,7 +111,7 @@ const build = async () => { | ||||
|   const rawIndexJs = util.format( | ||||
|     indexTemplate, | ||||
|     constantsString, | ||||
|     buildIcons.map(iconToKeyValue).join(','), | ||||
|     buildIcons.map(({ icon }) => iconToKeyValue(icon)).join(','), | ||||
|   ); | ||||
|   await writeJs(indexFile, rawIndexJs); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user