@@ -78,6 +78,23 @@ function isFileIgnoredByLibrary(file) {
7878 return ignored ;
7979}
8080
81+ function prunePathsWithinSymlinks ( paths ) {
82+ // Extracts symlinked paths and filters them out, including any child paths
83+ var symlinks = paths . filter ( function ( path ) {
84+ return fs . lstatSync ( path ) . isSymbolicLink ( ) ;
85+ } ) ;
86+
87+ return paths . filter ( function ( path ) {
88+ var withinSymlink = false ;
89+ symlinks . forEach ( function ( symlink ) {
90+ if ( path . indexOf ( symlink ) == 0 ) {
91+ withinSymlink = true ;
92+ }
93+ } ) ;
94+ return ! withinSymlink ;
95+ } ) ;
96+ }
97+
8198function exclusionBasedFileListBuilder ( excludePaths ) {
8299 // Uses glob to traverse code directory and find files to analyze,
83100 // excluding files passed in with by CLI config, and including only
@@ -88,7 +105,7 @@ function exclusionBasedFileListBuilder(excludePaths) {
88105 var analysisFiles = [ ] ;
89106 var allFiles = glob . sync ( "/code/**/**" , { } ) ;
90107
91- allFiles . forEach ( function ( file , i , a ) {
108+ prunePathsWithinSymlinks ( allFiles ) . forEach ( function ( file , i , a ) {
92109 if ( excludePaths . indexOf ( file . split ( "/code/" ) [ 1 ] ) < 0 ) {
93110 if ( fs . lstatSync ( file ) . isFile ( ) ) {
94111 if ( ! isFileIgnoredByLibrary ( file ) && isFileWithMatchingExtension ( file , extensions ) ) {
@@ -114,7 +131,7 @@ function inclusionBasedFileListBuilder(includePaths) {
114131 var filesInThisDirectory = glob . sync (
115132 "/code/" + fileOrDirectory + "/**/**"
116133 ) ;
117- filesInThisDirectory . forEach ( function ( file , j ) {
134+ prunePathsWithinSymlinks ( filesInThisDirectory ) . forEach ( function ( file , j ) {
118135 if ( ! isFileIgnoredByLibrary ( file ) && isFileWithMatchingExtension ( file , extensions ) ) {
119136 analysisFiles . push ( file ) ;
120137 }
0 commit comments