File tree Expand file tree Collapse file tree 1 file changed +27
-19
lines changed
Expand file tree Collapse file tree 1 file changed +27
-19
lines changed Original file line number Diff line number Diff line change @@ -37,29 +37,37 @@ console.log(`Checking ${slugs.length} slugs in ${locales.length} locales…`);
3737const result = { } ;
3838for ( const locale of locales ) {
3939 console . log ( `\n=== ${ locale } ===` ) ;
40- result [ locale ] = [ ] ;
40+ const missingSlugs = await Promise . all (
41+ slugs . map (
42+ /**
43+ * @param {string } slug
44+ * @returns {Promise<string[]> }
45+ */
46+ async ( slug ) => {
47+ const url = `https://developer.mozilla.org/${ locale } /docs/${ slug } ` ;
4148
42- for ( const slug of slugs ) {
43- const url = `https://developer.mozilla.org/ ${ locale } /docs/ ${ slug } ` ;
44- process . stdout . write ( `.` ) ;
49+ try {
50+ const res = await fetch ( url , { method : "HEAD" } ) ;
51+ process . stdout . write ( `.` ) ;
4552
46- try {
47- const res = await fetch ( url , { method : "HEAD" } ) ;
53+ if ( res . status === 200 ) {
54+ // All good.
55+ return [ ] ;
56+ } else if ( res . status === 404 ) {
57+ // Not found.
58+ } else {
59+ console . log ( `\n⚠️ HTTP ${ res . status } [${ url } ]` ) ;
60+ }
61+ } catch ( error ) {
62+ console . log ( `\n🔥 ERROR: ${ error } [${ url } ]` ) ;
63+ }
4864
49- if ( res . status === 200 ) {
50- // All good.
51- continue ;
52- } else if ( res . status === 404 ) {
53- // Not found.
54- } else {
55- console . log ( `\n⚠️ HTTP ${ res . status } [${ url } ]` ) ;
56- }
57- } catch ( error ) {
58- console . log ( `\n🔥 ERROR: ${ error } [${ url } ]` ) ;
59- }
65+ return [ slug ] ;
66+ } ,
67+ ) ,
68+ ) ;
6069
61- result [ locale ] . push ( slug ) ;
62- }
70+ result [ locale ] = missingSlugs . flat ( ) ;
6371}
6472
6573const file = path . join ( import . meta. dirname , "missing-docs.json" ) ;
You can’t perform that action at this time.
0 commit comments