@@ -78,6 +78,23 @@ function isFileIgnoredByLibrary(file) {
78
78
return ignored ;
79
79
}
80
80
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
+
81
98
function exclusionBasedFileListBuilder ( excludePaths ) {
82
99
// Uses glob to traverse code directory and find files to analyze,
83
100
// excluding files passed in with by CLI config, and including only
@@ -88,7 +105,7 @@ function exclusionBasedFileListBuilder(excludePaths) {
88
105
var analysisFiles = [ ] ;
89
106
var allFiles = glob . sync ( "/code/**/**" , { } ) ;
90
107
91
- allFiles . forEach ( function ( file , i , a ) {
108
+ prunePathsWithinSymlinks ( allFiles ) . forEach ( function ( file , i , a ) {
92
109
if ( excludePaths . indexOf ( file . split ( "/code/" ) [ 1 ] ) < 0 ) {
93
110
if ( fs . lstatSync ( file ) . isFile ( ) ) {
94
111
if ( ! isFileIgnoredByLibrary ( file ) && isFileWithMatchingExtension ( file , extensions ) ) {
@@ -114,7 +131,7 @@ function inclusionBasedFileListBuilder(includePaths) {
114
131
var filesInThisDirectory = glob . sync (
115
132
"/code/" + fileOrDirectory + "/**/**"
116
133
) ;
117
- filesInThisDirectory . forEach ( function ( file , j ) {
134
+ prunePathsWithinSymlinks ( filesInThisDirectory ) . forEach ( function ( file , j ) {
118
135
if ( ! isFileIgnoredByLibrary ( file ) && isFileWithMatchingExtension ( file , extensions ) ) {
119
136
analysisFiles . push ( file ) ;
120
137
}
0 commit comments