File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -24,8 +24,21 @@ export async function copyFiles (filesToServe: FileToServe[], destinationDirecto
24
24
if ( destinationFilePath . substr ( 0 , destinationDirectory . length ) !== destinationDirectory ) {
25
25
throw new Error ( `File would be served outside of destination directory: ${ sourcePath } => ${ servingPath } ` )
26
26
}
27
+
27
28
mkdirp . sync ( path . dirname ( destinationFilePath ) )
28
- return copyFile ( sourcePath , destinationFilePath )
29
+
30
+ if ( fs . statSync ( sourcePath ) . isDirectory ( ) ) {
31
+ const directoryFiles = fs . readdirSync ( sourcePath )
32
+ await copyFiles (
33
+ directoryFiles . map ( file => ( {
34
+ servingPath : path . join ( servingPath , file ) ,
35
+ sourcePath : path . join ( sourcePath , file )
36
+ } ) ) ,
37
+ destinationDirectory
38
+ )
39
+ } else {
40
+ await copyFile ( sourcePath , destinationFilePath )
41
+ }
29
42
}
30
43
) )
31
44
}
You can’t perform that action at this time.
0 commit comments