File tree Expand file tree Collapse file tree 1 file changed +4
-7
lines changed
Expand file tree Collapse file tree 1 file changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -141,16 +141,13 @@ async function zipDirectory(
141141 }
142142 throw err ;
143143 }
144- // For security, filter out all symlinks
145- const realFiles : typeof files = [ ] ;
146- await Promise . all (
144+ // For security, filter out all symlinks. This code is a bit obtuse to preserve ordering.
145+ const realFiles = ( await Promise . all (
147146 files . map ( async ( f ) => {
148147 const stats = await fs . promises . lstat ( f . name ) ;
149- if ( ! stats . isSymbolicLink ( ) ) {
150- realFiles . push ( f ) ;
151- }
148+ return stats . isSymbolicLink ( ) ? null : f ;
152149 } ) ,
153- ) ;
150+ ) ) . filter ( ( fileOrNull ) : fileOrNull is typeof files [ number ] => fileOrNull !== null ) ;
154151
155152 for ( const file of realFiles ) {
156153 const name = path . relative ( sourceDirectory , file . name ) ;
You can’t perform that action at this time.
0 commit comments