@@ -26,6 +26,7 @@ const serializeTrie = require("../lib/tries/serializeTrie");
26
26
const PUBLIC_SUFFIX_URL = "https://publicsuffix.org/list/public_suffix_list.dat" ;
27
27
const rootPath = path . resolve ( __dirname , ".." ) ;
28
28
const triesPath = path . resolve ( rootPath , "build" , "tries" ) ;
29
+ const metaJsonFilename = path . resolve ( triesPath , "meta.json" ) ;
29
30
const tries = [
30
31
{
31
32
listName : "icann" ,
@@ -59,7 +60,6 @@ got(PUBLIC_SUFFIX_URL, {timeout: 60 * 1000})
59
60
return {
60
61
path : path . resolve ( triesPath , trie . filename ) ,
61
62
content : JSON . stringify ( {
62
- updatedAt : new Date ( ) . toISOString ( ) ,
63
63
trie : serializeTrie ( parsedList , trie . type ) ,
64
64
} ) ,
65
65
} ;
@@ -80,14 +80,22 @@ got(PUBLIC_SUFFIX_URL, {timeout: 60 * 1000})
80
80
} ) ;
81
81
82
82
process . stderr . write ( "ok" + os . EOL ) ;
83
+
84
+ fs . writeFileSync (
85
+ metaJsonFilename ,
86
+ JSON . stringify ( {
87
+ updatedAt : new Date ( ) . toISOString ( ) ,
88
+ } ) ,
89
+ "utf8"
90
+ ) ;
83
91
} )
84
92
. catch ( err => {
85
93
console . error ( "" ) ;
86
94
console . error ( `Could not update list of known top-level domains for parse-domain because of "${ err . message } "` ) ;
87
95
88
- const prebuiltList = JSON . parse ( fs . readFileSync ( path . resolve ( triesPath , tries [ 0 ] . filename ) , "utf8" ) ) ;
96
+ const metaJson = JSON . parse ( fs . readFileSync ( metaJsonFilename , "utf8" ) ) ;
89
97
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 ( ) ) ;
91
99
92
100
// We can recover using the (possibly outdated) prebuilt list, hence exit code 0
93
101
process . exit ( 0 ) ; // eslint-disable-line no-process-exit
0 commit comments