@@ -26,6 +26,7 @@ const serializeTrie = require("../lib/tries/serializeTrie");
2626const PUBLIC_SUFFIX_URL = "https://publicsuffix.org/list/public_suffix_list.dat" ;
2727const rootPath = path . resolve ( __dirname , ".." ) ;
2828const triesPath = path . resolve ( rootPath , "build" , "tries" ) ;
29+ const metaJsonFilename = path . resolve ( triesPath , "meta.json" ) ;
2930const tries = [
3031 {
3132 listName : "icann" ,
@@ -59,7 +60,6 @@ got(PUBLIC_SUFFIX_URL, {timeout: 60 * 1000})
5960 return {
6061 path : path . resolve ( triesPath , trie . filename ) ,
6162 content : JSON . stringify ( {
62- updatedAt : new Date ( ) . toISOString ( ) ,
6363 trie : serializeTrie ( parsedList , trie . type ) ,
6464 } ) ,
6565 } ;
@@ -80,14 +80,22 @@ got(PUBLIC_SUFFIX_URL, {timeout: 60 * 1000})
8080 } ) ;
8181
8282 process . stderr . write ( "ok" + os . EOL ) ;
83+
84+ fs . writeFileSync (
85+ metaJsonFilename ,
86+ JSON . stringify ( {
87+ updatedAt : new Date ( ) . toISOString ( ) ,
88+ } ) ,
89+ "utf8"
90+ ) ;
8391 } )
8492 . catch ( err => {
8593 console . error ( "" ) ;
8694 console . error ( `Could not update list of known top-level domains for parse-domain because of "${ err . message } "` ) ;
8795
88- const prebuiltList = JSON . parse ( fs . readFileSync ( path . resolve ( triesPath , tries [ 0 ] . filename ) , "utf8" ) ) ;
96+ const metaJson = JSON . parse ( fs . readFileSync ( metaJsonFilename , "utf8" ) ) ;
8997
90- console . error ( "Using possibly outdated prebuilt list from " + new Date ( prebuiltList . updatedAt ) . toDateString ( ) ) ;
98+ console . error ( "Using possibly outdated prebuilt list from " + new Date ( metaJson . updatedAt ) . toDateString ( ) ) ;
9199
92100 // We can recover using the (possibly outdated) prebuilt list, hence exit code 0
93101 process . exit ( 0 ) ; // eslint-disable-line no-process-exit
0 commit comments