@@ -13,7 +13,10 @@ async function listFiles(dir: string, extension: string, depth: number): Promise
13
13
const files = await Promise . all (
14
14
dirents . map ( dirent => {
15
15
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 ;
17
20
} ) ,
18
21
) ;
19
22
return ( [ ] as FsItem [ ] ) . concat ( ...files ) ;
@@ -27,9 +30,13 @@ export async function listRepoFiles(
27
30
folder : string ,
28
31
extension : string ,
29
32
depth : number ,
30
- ) {
33
+ ) : Promise < FsItem [ ] > {
31
34
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
+ } ) ;
33
40
}
34
41
35
42
export async function writeFile ( filePath : string , content : Buffer | string ) {
@@ -54,7 +61,9 @@ export async function move(from: string, to: string) {
54
61
const sourceDir = path . dirname ( from ) ;
55
62
const destDir = path . dirname ( to ) ;
56
63
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
+ ) ;
58
67
}
59
68
60
69
export async function getUpdateDate ( repoPath : string , filePath : string ) {
0 commit comments