@@ -49,13 +49,12 @@ function buildSprite(
4949 let symbols = ''
5050 Object . entries ( grouped ) . forEach ( ( [ prefix , iconNames ] ) => {
5151 const collection = collections [ prefix ]
52-
5352 if ( ! collection ?. icons ) return
5453
5554 const defaultWidth = collection . width ?? 16
5655 const defaultHeight = collection . height ?? 16
5756
58- iconNames . forEach ( name => {
57+ new Set ( iconNames ) . forEach ( name => {
5958 const icon = collection . icons [ name ]
6059
6160 if ( ! icon ?. body ) return
@@ -70,30 +69,23 @@ function buildSprite(
7069 return `<svg xmlns="http://www.w3.org/2000/svg" style="display:none">${ symbols } </svg>\n`
7170}
7271
73- async function main ( ) {
74- const collections = await loadCollections ( )
75- const iconNames = [
76- ...Object . values ( EXTENSION_ICONS ) ,
77- ...Object . values ( FILENAME_ICONS ) ,
78- ...Object . values ( COMPOUND_EXTENSIONS ) ,
79- ...Object . values ( ADDITIONAL_ICONS ) ,
80- DEFAULT_ICON ,
81- ]
82- const grouped = groupByCollection ( iconNames )
83- const sprite = buildSprite ( grouped , collections )
84- await Promise . all ( [
85- fs . mkdir ( path . dirname ( outputDevPath ) , { recursive : true } ) ,
86- fs . mkdir ( path . dirname ( outputStagePath ) , { recursive : true } ) ,
87- fs . mkdir ( path . dirname ( outputProdPath ) , { recursive : true } ) ,
88- ] )
89- await Promise . all ( [
90- fs . writeFile ( outputDevPath , sprite , 'utf8' ) ,
91- fs . writeFile ( outputStagePath , sprite , 'utf8' ) ,
92- fs . writeFile ( outputProdPath , sprite , 'utf8' ) ,
93- ] )
94- }
95-
96- main ( ) . catch ( error => {
97- console . error ( error )
98- process . exitCode = 1
99- } )
72+ const collections = await loadCollections ( )
73+ const iconNames = [
74+ ...Object . values ( EXTENSION_ICONS ) ,
75+ ...Object . values ( FILENAME_ICONS ) ,
76+ ...Object . values ( COMPOUND_EXTENSIONS ) ,
77+ ...Object . values ( ADDITIONAL_ICONS ) ,
78+ DEFAULT_ICON ,
79+ ]
80+ const grouped = groupByCollection ( iconNames )
81+ const sprite = buildSprite ( grouped , collections )
82+ await Promise . all ( [
83+ fs . mkdir ( path . dirname ( outputDevPath ) , { recursive : true } ) ,
84+ fs . mkdir ( path . dirname ( outputStagePath ) , { recursive : true } ) ,
85+ fs . mkdir ( path . dirname ( outputProdPath ) , { recursive : true } ) ,
86+ ] )
87+ await Promise . all ( [
88+ fs . writeFile ( outputDevPath , sprite , 'utf8' ) ,
89+ fs . writeFile ( outputStagePath , sprite , 'utf8' ) ,
90+ fs . writeFile ( outputProdPath , sprite , 'utf8' ) ,
91+ ] )
0 commit comments