@@ -8,30 +8,27 @@ import { createRequire } from 'module';
8
8
const __filename = fileURLToPath ( import . meta. url ) ;
9
9
const __dirname = dirname ( __filename ) ;
10
10
const require = createRequire ( __dirname ) ;
11
+ const folders = [ '.' , ...Object . keys ( require ( path . join ( __dirname , './package.json' ) ) . directories ) ] ;
12
+ const files = [ ] ;
11
13
12
- let folders = [ '.' , ...Object . keys ( require ( path . join ( __dirname , './package.json' ) ) . directories ) ] ;
13
- let files = [ ] ;
14
-
15
- for ( let folder of folders ) {
14
+ folders . forEach ( folder => {
16
15
try {
17
- for ( let file of fs . readdirSync ( folder ) . filter ( v => v . endsWith ( '.js' ) ) ) {
18
- files . push ( path . resolve ( path . join ( folder , file ) ) ) ;
19
- }
16
+ const jsFiles = fs . readdirSync ( folder ) . filter ( v => v . endsWith ( '.js' ) ) . map ( file => path . resolve ( folder , file ) ) ;
17
+ files . push ( ...jsFiles ) ;
20
18
} catch ( err ) {
21
19
console . error ( `Error reading folder ${ folder } :` , err ) ;
22
20
}
23
- }
21
+ } ) ;
24
22
25
- for ( let file of files ) {
26
- if ( file == __filename ) continue ;
27
- console . error ( 'Checking' , file ) ;
28
-
29
- const error = syntaxError ( fs . readFileSync ( file , 'utf8' ) , file , {
30
- sourceType : 'module' ,
31
- allowReturnOutsideFunction : true ,
32
- allowAwaitOutsideFunction : true
33
- } ) ;
34
-
35
- assert . ifError ( error ) ;
36
- console . log ( 'Done ☑️' , file ) ;
37
- }
23
+ files . forEach ( file => {
24
+ if ( file !== __filename ) {
25
+ console . error ( 'Checking' , file ) ;
26
+ const error = syntaxError ( fs . readFileSync ( file , 'utf8' ) , file , {
27
+ sourceType : 'module' ,
28
+ allowReturnOutsideFunction : true ,
29
+ allowAwaitOutsideFunction : true
30
+ } ) ;
31
+ assert . ifError ( error ) ;
32
+ console . log ( 'Done ☑️' , file ) ;
33
+ }
34
+ } ) ;
0 commit comments