@@ -12,7 +12,7 @@ const { readdirSync, readFileSync } = require("fs");
12
12
const { join } = require ( "path" ) ;
13
13
14
14
const remark = require ( "remark" ) ;
15
- const remarkTwoSlash = require ( "gatsby- remark-shiki-twoslash" ) ;
15
+ const remarkTwoSlash = require ( "remark-shiki-twoslash" ) ;
16
16
17
17
const { read } = require ( "gray-matter" ) ;
18
18
@@ -25,62 +25,65 @@ const filterString = process.argv[2] ? process.argv[2] : "";
25
25
26
26
const errorReports = [ ] ;
27
27
28
- languages . forEach ( ( lang ) => {
29
- console . log ( "\n\nLanguage: " + chalk . bold ( lang ) + "\n" ) ;
28
+ const go = async ( ) => {
29
+ for ( const lang of languages ) {
30
+ console . log ( "\n\nLanguage: " + chalk . bold ( lang ) + "\n" ) ;
30
31
31
- const locale = join ( __dirname , ".." , "copy" , lang ) ;
32
- let options ;
32
+ const locale = join ( __dirname , ".." , "copy" , lang ) ;
33
+ let options ;
33
34
34
- try {
35
- options = readdirSync ( join ( locale ) ) . filter ( ( f ) => ! f . startsWith ( "." ) ) ;
36
- } catch {
37
- errorReports . push ( {
38
- path : join ( locale , "options" ) ,
39
- error : `Options directory ${ join ( locale , "options" ) } doesn't exist` ,
40
- } ) ;
41
- return ;
42
- }
35
+ try {
36
+ options = readdirSync ( join ( locale ) ) . filter ( ( f ) => ! f . startsWith ( "." ) ) ;
37
+ } catch {
38
+ errorReports . push ( {
39
+ path : join ( locale , "options" ) ,
40
+ error : `Options directory ${ join ( locale , "options" ) } doesn't exist` ,
41
+ } ) ;
42
+ return ;
43
+ }
43
44
44
- options . forEach ( ( option ) => {
45
- if ( filterString . length && ! option . includes ( filterString ) ) return ;
45
+ for ( const option of options ) {
46
+ if ( filterString . length && ! option . includes ( filterString ) ) return ;
46
47
47
- const optionPath = join ( locale , option ) ;
48
+ const optionPath = join ( locale , option ) ;
48
49
49
- const markdown = readFileSync ( optionPath , "utf8" ) ;
50
- const markdownAST = remark ( ) . parse ( markdown ) ;
51
- let hasError = false ;
50
+ const markdown = readFileSync ( optionPath , "utf8" ) ;
51
+ const markdownAST = remark ( ) . parse ( markdown ) ;
52
+ let hasError = false ;
52
53
53
- try {
54
- remarkTwoSlash . runTwoSlashAcrossDocument ( { markdownAST } , { } ) ;
55
- } catch ( error ) {
56
- hasError = true ;
57
- errorReports . push ( { path : optionPath , error } ) ;
58
- }
54
+ try {
55
+ await remarkTwoSlash . default ( { } ) ( markdownAST ) ;
56
+ } catch ( error ) {
57
+ hasError = true ;
58
+ errorReports . push ( { path : optionPath , error } ) ;
59
+ }
59
60
60
- const optionFile = read ( optionPath ) ;
61
- if ( ! optionFile . data . display ) {
62
- hasError = true ;
63
- // prettier-ignore
64
- errorReports . push ( { path : optionPath , error : new Error ( "Did not have a 'display' property in the YML header" ) } ) ;
61
+ const optionFile = read ( optionPath ) ;
62
+ if ( ! optionFile . data . display ) {
63
+ hasError = true ;
64
+ // prettier-ignore
65
+ errorReports . push ( { path : optionPath , error : new Error ( "Did not have a 'display' property in the YML header" ) } ) ;
66
+ }
67
+
68
+ const sigil = hasError ? cross : tick ;
69
+ const name = hasError ? chalk . red ( option ) : option ;
70
+ process . stdout . write ( name + " " + sigil + ", " ) ;
65
71
}
72
+ }
73
+
74
+ if ( errorReports . length ) {
75
+ process . exitCode = 1 ;
66
76
67
- const sigil = hasError ? cross : tick ;
68
- const name = hasError ? chalk . red ( option ) : option ;
69
- process . stdout . write ( name + " " + sigil + ", " ) ;
70
- } ) ;
71
- } ) ;
72
-
73
- if ( errorReports . length ) {
74
- process . exitCode = 1 ;
75
-
76
- errorReports . forEach ( ( err ) => {
77
- console . log ( `\n> ${ chalk . bold . red ( err . path ) } \n` ) ;
78
- err . error . stack = undefined ;
79
- console . log ( err . error ) ;
80
- } ) ;
81
- console . log ( "\n\n" ) ;
82
-
83
- console . log (
84
- "Note: you can add an extra argument to the lint script ( yarn workspace glossary lint [opt] ) to just run one lint."
85
- ) ;
86
- }
77
+ errorReports . forEach ( ( err ) => {
78
+ console . log ( `\n> ${ chalk . bold . red ( err . path ) } \n` ) ;
79
+ err . error . stack = undefined ;
80
+ console . log ( err . error ) ;
81
+ } ) ;
82
+ console . log ( "\n\n" ) ;
83
+
84
+ console . log (
85
+ "Note: you can add an extra argument to the lint script ( yarn workspace glossary lint [opt] ) to just run one lint."
86
+ ) ;
87
+ }
88
+ } ;
89
+ go ( ) ;
0 commit comments