1
+ using System ;
1
2
using System . Collections . Generic ;
2
3
using System . IO ;
3
4
using System . Linq ;
@@ -120,6 +121,24 @@ private static FileInfo[] GetDefaultFiles()
120
121
}
121
122
}
122
123
124
+ /// <summary>
125
+ /// Returns true if the extractor should skip files in the PSModulePath because the
126
+ /// environment variable CODEQL_EXTRACTOR_POWERSHELL_OPTION_SKIP_PSMODULEPATH_FILES
127
+ /// is set to a truthy value.
128
+ /// </summary>
129
+ private static bool GetDefaultSkipPSModulePathFiles ( )
130
+ {
131
+ var skip = System . Environment . GetEnvironmentVariable (
132
+ "CODEQL_EXTRACTOR_POWERSHELL_OPTION_SKIP_PSMODULEPATH_FILES"
133
+ ) ;
134
+ bool b = skip != null && skip . ToLower ( ) != "false" ;
135
+ if ( b )
136
+ {
137
+ System . Console . WriteLine ( "Skipping files in PSModulePath" ) ;
138
+ }
139
+ return b ;
140
+ }
141
+
123
142
/// <summary>
124
143
/// The directory or file containing the source code;
125
144
/// </summary>
@@ -134,7 +153,7 @@ private static FileInfo[] GetDefaultFiles()
134
153
/// Whether to extract files in the paths found in the `PSModulePath`
135
154
/// environment variable.
136
155
/// </summary>
137
- public bool SkipPSModulePathFiles { get ; private set ; } = false ;
156
+ public bool SkipPSModulePathFiles { get ; private set ; } = GetDefaultSkipPSModulePathFiles ( ) ;
138
157
139
158
/// <summary>
140
159
/// Whether errors were encountered parsing the arguments.
@@ -172,9 +191,13 @@ public static void ShowHelp(System.IO.TextWriter output)
172
191
" --exclude:xxx Exclude a file or directory (can be specified multiple times)"
173
192
) ;
174
193
output . WriteLine ( " --dry-run Stop before extraction" ) ;
175
- output . WriteLine ( " --threads:nnn Specify number of threads (default=CPU cores)" ) ;
194
+ output . WriteLine (
195
+ " --threads:nnn Specify number of threads (default=CPU cores)"
196
+ ) ;
176
197
output . WriteLine ( " --verbose Produce more output" ) ;
177
- output . WriteLine ( " --skip-psmodulepath-files Avoid extracting source files in paths specified by the PSModulePath environment variable." ) ;
198
+ output . WriteLine (
199
+ " --skip-psmodulepath-files Avoid extracting source files in paths specified by the PSModulePath environment variable."
200
+ ) ;
178
201
}
179
202
180
203
private Options ( ) { }
0 commit comments