@@ -70,34 +70,26 @@ const ignoredTestFiles = [
70
70
* Load all test file contents with acquit
71
71
* @returns {Object[] } acquit ast array
72
72
*/
73
- async function getTests ( ) {
74
- const promiseArray = [ ] ;
75
-
76
- for ( const file of additionalTestFiles ) {
77
- const filePath = path . join ( testPath , file ) ;
78
- promiseArray . push ( fs . promises . readFile ( filePath ) . then ( v => ( { value : v . toString ( ) , path : filePath } ) ) ) ;
79
- }
80
-
73
+ function getTests ( ) {
81
74
const testDocs = path . resolve ( testPath , 'docs' ) ;
75
+ const filesToScan = [
76
+ ...additionalTestFiles . map ( v => path . join ( testPath , v ) ) ,
77
+ ...fs . readdirSync ( testDocs ) . filter ( v => ! ignoredTestFiles . includes ( v ) ) . map ( v => path . join ( testDocs , v ) )
78
+ ] ;
82
79
83
- for ( const file of await fs . promises . readdir ( testDocs ) ) {
84
- if ( ignoredTestFiles . includes ( file ) ) {
85
- continue ;
86
- }
80
+ const retArray = [ ] ;
87
81
88
- const filePath = path . join ( testDocs , file ) ;
89
- promiseArray . push ( fs . promises . readFile ( filePath ) . then ( v => ( { value : v . toString ( ) , path : filePath } ) ) ) ;
90
- }
91
-
92
- return ( await Promise . all ( promiseArray ) ) . flatMap ( v => {
82
+ for ( const file of filesToScan ) {
93
83
try {
94
- return acquit . parse ( v . value ) ;
84
+ retArray . push ( acquit . parse ( fs . readFileSync ( file ) . toString ( ) ) ) ;
95
85
} catch ( err ) {
96
86
// add a file path to a acquit error, for better debugging
97
- err . filePath = v . path ;
87
+ err . filePath = file ;
98
88
throw err ;
99
89
}
100
- } )
90
+ }
91
+
92
+ return retArray . flat ( ) ;
101
93
}
102
94
103
95
/**
@@ -376,7 +368,7 @@ async function pugify(filename, options, isReload = false) {
376
368
let contents = fs . readFileSync ( path . resolve ( cwd , inputFile ) ) . toString ( ) ;
377
369
378
370
if ( options . acquit ) {
379
- contents = transform ( contents , await getTests ( ) ) ;
371
+ contents = transform ( contents , getTests ( ) ) ;
380
372
381
373
contents = contents . replaceAll ( / ^ ` ` ` a c q u i t $ / gmi, "```javascript" ) ;
382
374
}
0 commit comments