@@ -5,14 +5,15 @@ import grayMatter from "gray-matter";
5
5
6
6
const files = await readdir ( "." , { withFileTypes : true } ) ;
7
7
const dirs = files . filter (
8
- ( f ) => f . isDirectory ( ) && ! f . name . startsWith ( "." ) && f . name !== "node_modules"
8
+ ( f ) =>
9
+ f . isDirectory ( ) && ! f . name . startsWith ( "." ) && f . name !== "node_modules" ,
9
10
) ;
10
11
11
12
let badExit = false ;
12
13
13
14
// error reports an error to the console and sets badExit to true
14
15
// so that the process will exit with a non-zero exit code.
15
- const error = ( ...data : any [ ] ) => {
16
+ const error = ( ...data : unknown [ ] ) => {
16
17
console . error ( ...data ) ;
17
18
badExit = true ;
18
19
} ;
@@ -22,15 +23,20 @@ const verifyCodeBlocks = (
22
23
res = {
23
24
codeIsTF : false ,
24
25
codeIsHCL : false ,
25
- }
26
+ } ,
26
27
) => {
27
28
for ( const token of tokens ) {
28
29
// Check in-depth.
29
30
if ( token . type === "list" ) {
30
31
verifyCodeBlocks ( token . items , res ) ;
31
32
continue ;
32
33
}
34
+
33
35
if ( token . type === "list_item" ) {
36
+ if ( token . tokens === undefined ) {
37
+ throw new Error ( "Tokens are missing for type list_item" ) ;
38
+ }
39
+
34
40
verifyCodeBlocks ( token . tokens , res ) ;
35
41
continue ;
36
42
}
@@ -80,8 +86,9 @@ for (const dir of dirs) {
80
86
if ( ! data . maintainer_github ) {
81
87
error ( dir . name , "missing maintainer_github" ) ;
82
88
}
89
+
83
90
try {
84
- await stat ( path . join ( "." , dir . name , data . icon ) ) ;
91
+ await stat ( path . join ( "." , dir . name , data . icon ?? "" ) ) ;
85
92
} catch ( ex ) {
86
93
error ( dir . name , "icon does not exist" , data . icon ) ;
87
94
}
0 commit comments