@@ -82,14 +82,45 @@ public override void InvalidArgument(string argument)
8282 public IList < string > Excludes { get ; } =
8383 new List < string > ( ) { "node_modules" , "bower_components" } ;
8484
85+ /// <summary>
86+ /// Returns a FileInfo object for each file in the given path (recursively).
87+ /// </summary>
88+ private static FileInfo [ ] GetFiles ( string path )
89+ {
90+ var di = new DirectoryInfo ( path ) ;
91+ return di . Exists
92+ ? di . GetFiles ( "*.*" , SearchOption . AllDirectories )
93+ : new FileInfo [ ] { new FileInfo ( path ) } ;
94+ }
95+
96+ /// <summary>
97+ /// Returns a list of files to extract. By default, this is the list of all files in
98+ /// the current directory. However, if the LGTM_INDEX_INCLUDE environment variable is
99+ /// set, it is used as a list of files to include instead of the files from the current
100+ /// directory.
101+ /// </summary>
102+ private static FileInfo [ ] GetDefaultFiles ( )
103+ {
104+ // Check if the LGTM_INDEX_INCLUDE environmen variable exists
105+ var include = System . Environment . GetEnvironmentVariable ( "LGTM_INDEX_INCLUDE" ) ;
106+ if ( include != null )
107+ {
108+ System . Console . WriteLine ( "Using LGTM_INDEX_INCLUDE: {0}" , include ) ;
109+ return include . Split ( ';' ) . Select ( GetFiles ) . SelectMany ( f => f ) . ToArray ( ) ;
110+ }
111+ else
112+ {
113+ return new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) . GetFiles (
114+ "*.*" ,
115+ SearchOption . AllDirectories
116+ ) ;
117+ }
118+ }
119+
85120 /// <summary>
86121 /// The directory or file containing the source code;
87122 /// </summary>
88- public FileInfo [ ] Files { get ; set ; } =
89- new DirectoryInfo ( Directory . GetCurrentDirectory ( ) ) . GetFiles (
90- "*.*" ,
91- SearchOption . AllDirectories
92- ) ;
123+ public FileInfo [ ] Files { get ; set ; } = GetDefaultFiles ( ) ;
93124
94125 /// <summary>
95126 /// Whether the extraction phase should be skipped (dry-run).
0 commit comments