@@ -85,21 +85,21 @@ export function flattenObject(data: any) {
85
85
return result ;
86
86
}
87
87
88
- export async function iterateFolder ( folderPath : string , callback : ( filePath : string ) => void | Promise < void > , extension = '.js' ) {
88
+ export async function iterateFolder ( folderPath : string , callback : ( filePath : string ) => void | Promise < void > , extensions = [ '.js' , '.ts' ] ) {
89
89
const files = await fs . readdir ( folderPath ) ;
90
90
await Promise . all (
91
91
files . map ( async ( file ) => {
92
92
const filePath = path . join ( folderPath , file ) ;
93
93
const stat = await fs . lstat ( filePath ) ;
94
94
if ( stat . isSymbolicLink ( ) ) {
95
95
const realPath = await fs . readlink ( filePath ) ;
96
- if ( stat . isFile ( ) && file . endsWith ( extension ) ) {
96
+ if ( stat . isFile ( ) && extensions . find ( e => realPath . endsWith ( e ) ) ) {
97
97
await callback ( realPath ) ;
98
98
} else if ( stat . isDirectory ( ) ) {
99
- await iterateFolder ( realPath , callback , extension ) ;
99
+ await iterateFolder ( realPath , callback , extensions ) ;
100
100
}
101
- } else if ( stat . isFile ( ) && file . endsWith ( extension ) ) await callback ( filePath ) ;
102
- else if ( stat . isDirectory ( ) ) await iterateFolder ( filePath , callback , extension ) ;
101
+ } else if ( stat . isFile ( ) && extensions . find ( e => file . endsWith ( e ) ) ) await callback ( filePath ) ;
102
+ else if ( stat . isDirectory ( ) ) await iterateFolder ( filePath , callback , extensions ) ;
103
103
} )
104
104
) ;
105
105
}
0 commit comments