@@ -13,7 +13,10 @@ async function listFiles(dir: string, extension: string, depth: number): Promise
1313 const files = await Promise . all (
1414 dirents . map ( dirent => {
1515 const res = path . join ( dir , dirent . name ) ;
16- return { file : [ res ] . filter ( f => f . endsWith ( extension ) ) [ 0 ] , isDirectory : dirent . isDirectory ( ) } as FsItem ;
16+ return {
17+ file : [ res ] . filter ( f => f . endsWith ( extension ) ) [ 0 ] ,
18+ isDirectory : dirent . isDirectory ( ) ,
19+ } as FsItem ;
1720 } ) ,
1821 ) ;
1922 return ( [ ] as FsItem [ ] ) . concat ( ...files ) ;
@@ -27,9 +30,13 @@ export async function listRepoFiles(
2730 folder : string ,
2831 extension : string ,
2932 depth : number ,
30- ) {
33+ ) : Promise < FsItem [ ] > {
3134 const files = await listFiles ( path . join ( repoPath , folder ) , extension , depth ) ;
32- return files . map ( f => { return { file : f . file . slice ( repoPath . length + 1 ) , isDirectory : f . isDirectory } as FsItem } ) ;
35+ return files
36+ . filter ( f => f . file )
37+ . map ( f => {
38+ return { file : f . file . slice ( repoPath . length + 1 ) , isDirectory : f . isDirectory } as FsItem ;
39+ } ) ;
3340}
3441
3542export async function writeFile ( filePath : string , content : Buffer | string ) {
@@ -54,7 +61,9 @@ export async function move(from: string, to: string) {
5461 const sourceDir = path . dirname ( from ) ;
5562 const destDir = path . dirname ( to ) ;
5663 const allFiles = await listFiles ( sourceDir , '' , 100 ) ;
57- await Promise . all ( allFiles . map ( item => moveFile ( item . file , item . file . replace ( sourceDir , destDir ) ) ) ) ;
64+ await Promise . all (
65+ allFiles . map ( item => moveFile ( item . file , item . file . replace ( sourceDir , destDir ) ) ) ,
66+ ) ;
5867}
5968
6069export async function getUpdateDate ( repoPath : string , filePath : string ) {
0 commit comments