@@ -36,6 +36,7 @@ async function main() {
3636 console . log ( `INFO: starting at ${ new Date ( ) . toISOString ( ) } ` ) ;
3737
3838 const gemojiPath = path . join ( __dirname , '..' , 'tmp' , 'gemoji.json' ) ;
39+ const emojilibPath = path . join ( __dirname , '..' , 'tmp' , 'emojilib.json' ) ;
3940 const jsonPath = path . join ( __dirname , '..' , 'public' , 'emoji.json' ) ;
4041
4142 try {
@@ -56,6 +57,19 @@ async function main() {
5657 gemojiMap . set ( entry . emoji , entry ) ;
5758 }
5859
60+ try {
61+ await fs . access ( emojilibPath ) ;
62+ } catch ( err ) {
63+ console . log ( `INFO: emojilib file does not exist in ${ emojilibPath } ` ) ;
64+ process . exit ( 1 ) ;
65+ }
66+
67+ // Read and parse the emojilib file
68+ console . log ( `INFO: reading file from ${ emojilibPath } ` ) ;
69+ const emojilibData = await fs . readFile ( emojilibPath , "utf-8" ) ;
70+ console . log ( `INFO: parsing emojilib data` ) ;
71+ const emojilibMap = JSON . parse ( emojilibData ) as { [ key : string ] : string [ ] } ;
72+
5973 try {
6074 await fs . access ( jsonPath ) ;
6175 } catch ( err ) {
@@ -70,14 +84,21 @@ async function main() {
7084 const data = JSON . parse ( rawData ) as SearchData ;
7185
7286 for ( const row of data . data ) {
87+ const newTags = new Set < string > ( ) ;
7388 const gemojiEntry = gemojiMap . get ( row . emoji ) ;
7489 if ( ! gemojiEntry ) {
7590 console . log ( `WARN: no gemoji entry found for emoji ${ row . emoji } (${ row . description } )` ) ;
76- continue ;
91+ }
92+ else {
93+ gemojiEntry . tags . forEach ( newTags . add , newTags ) ;
94+ gemojiEntry . aliases . forEach ( newTags . add , newTags ) ;
95+ }
96+
97+ const emojilibKeywords = emojilibMap [ row . emoji ] ;
98+ if ( emojilibKeywords ) {
99+ emojilibKeywords . forEach ( newTags . add , newTags ) ;
77100 }
78101
79- // merge tags and aliases
80- const newTags = new Set < string > ( [ ...gemojiEntry . tags , ...gemojiEntry . aliases ] ) ;
81102 if ( newTags . size === 0 ) {
82103 continue ;
83104 }
0 commit comments