@@ -272,40 +272,41 @@ async function getFilesFromFs(dir, rootPath, ig, options) {
272272 path . relative ( rootPath , fullPath ) ,
273273 )
274274 const ignore = ig . ignores ( path . relative ( '/' , relativePath ) )
275- if ( ! ignore ) {
276- const fileObj = {
277- name : file . name ,
278- path : fullPath ,
279- relativePath,
280- }
281- // Three cases to consider: directories, files, symlinks
282- if ( file . isDirectory ( ) ) {
283- await recursiveMerge ( fullPath )
284- } else if ( file . isSymbolicLink ( ) ) {
285- // Allow skipping symbolic links which lead to recursion
286- // Disabling this is a big performance advantage on high latency
287- // storage but it's a good default for versatility
288- if ( ! options . ignoreSymlinks ) {
289- try {
290- const targetPath = await fs . promises . realpath ( fullPath )
291- const targetStat = await fs . promises . stat ( targetPath )
292- // Either add or recurse from the target depending
293- if ( targetStat . isDirectory ( ) ) {
294- await recursiveMerge ( targetPath )
295- } else {
296- filesAccumulator . push ( fileObj )
297- }
298- } catch ( err ) {
299- // Symlink points at an invalid target, skip it
300- return
275+ const fileObj = {
276+ name : file . name ,
277+ path : fullPath ,
278+ relativePath,
279+ }
280+ if ( ignore ) {
281+ fileObj . ignore = true
282+ }
283+ // Three cases to consider: directories, files, symlinks
284+ if ( file . isDirectory ( ) ) {
285+ await recursiveMerge ( fullPath )
286+ } else if ( file . isSymbolicLink ( ) ) {
287+ // Allow skipping symbolic links which lead to recursion
288+ // Disabling this is a big performance advantage on high latency
289+ // storage but it's a good default for versatility
290+ if ( ! options . ignoreSymlinks ) {
291+ try {
292+ const targetPath = await fs . promises . realpath ( fullPath )
293+ const targetStat = await fs . promises . stat ( targetPath )
294+ // Either add or recurse from the target depending
295+ if ( targetStat . isDirectory ( ) ) {
296+ await recursiveMerge ( targetPath )
297+ } else {
298+ filesAccumulator . push ( fileObj )
301299 }
302- } else {
303- // This branch assumes all symbolic links are not directories
304- filesAccumulator . push ( fileObj )
300+ } catch ( err ) {
301+ // Symlink points at an invalid target, skip it
302+ return
305303 }
306304 } else {
305+ // This branch assumes all symbolic links are not directories
307306 filesAccumulator . push ( fileObj )
308307 }
308+ } else {
309+ filesAccumulator . push ( fileObj )
309310 }
310311 }
311312 return filesAccumulator
0 commit comments