55 be parsing. So, we open the old fontawesome-v5.js file (which was
66 made for web, not node), read it in, make adjustments, and eval it
77 (yeah I know, eval bad). Then we make a map of fonts and the
8- prefixes to we can add the prefix back. If it's a new font, we make
8+ prefixes so we can add the prefix back. If it's a new font, we make
99 the prefix '---' so we can search the file for it and hand-curate
10- the prefix manually. Then, we have a fiished file.
10+ the prefix manually. Then, we have a finished file.
1111*/
12- const fs = require ( 'fs' )
1312const path = require ( 'path' )
13+ const { green, blue } = require ( 'chalk' )
14+ const { readFile, writeFile } = require ( '../utils' )
1415
1516const name = 'fontawesome-v5'
1617const inputLocation = `../../src/component/icon-set/${ name } .js`
@@ -21,7 +22,7 @@ let blacklisted = [
2122 'fa-font-awesome-logo-full'
2223]
2324
24- let fa = fs . readFileSync ( path . resolve ( __dirname , inputLocation ) , 'utf8' )
25+ let fa = readFile ( path . resolve ( __dirname , inputLocation ) )
2526fa = fa . split ( '\n' )
2627fa . shift ( )
2728fa . shift ( )
@@ -38,7 +39,7 @@ fa.forEach(f => {
3839} )
3940
4041const location = require . resolve ( '@quasar/extras/fontawesome-v5/fontawesome-v5.css' )
41- const fileContents = fs . readFileSync ( location , 'utf8' )
42+ const fileContents = readFile ( location )
4243
4344fileContents
4445 . split ( '\n' )
@@ -58,16 +59,16 @@ fileContents
5859 }
5960 } )
6061
61- let output = 'export default {\n'
62- output += ` name: ${ name } ,\n`
63- output += ' icons: [\n'
62+ let output = 'export default {\n'
63+ output += ` name: ' ${ name } ' ,\n`
64+ output += ' icons: [\n'
6465
65- icons . forEach ( ( icon , index ) => {
66- output += ` { name: '${ icon } ' },\n`
67- } )
66+ icons . forEach ( ( icon , index ) => {
67+ output += ` { name: '${ icon } ' },\n`
68+ } )
6869
69- output += ' ]\n'
70- output += '}\n'
70+ output += ' ]\n'
71+ output += '}\n'
7172
72- fs . writeFileSync ( path . resolve ( __dirname , outputLocation ) , output , 'utf8' )
73- console . log ( `Fontawesome v5 Icons generation: Done - count: ${ icons . length } ` )
73+ writeFile ( path . resolve ( __dirname , outputLocation ) , output )
74+ console . log ( `${ blue ( '[icon]' ) } ${ green ( name + ':' ) } ${ icons . length } generated ` )
0 commit comments