@@ -13,6 +13,7 @@ export const FIELDS = {
1313 CONFIG_ROOT : 'config_root' ,
1414 LOG_FOLDER : 'log_folder' ,
1515 LOG_LEVEL : 'log_level' ,
16+ ROOT_WORKING_FOLDER : 'root_working_folder' , // Hidden
1617 CUSTOM_ENGINE_PLUGIN_MODULES : 'custom_engine_plugin_modules' , // Hidden
1718 PRESERVE_ALL_WORKING_FOLDERS : 'preserve_all_working_folders' , // Hidden
1819 RULES : 'rules' ,
@@ -42,6 +43,7 @@ type TopLevelConfig = {
4243 log_level : LogLevel
4344 rules : Record < string , RuleOverrides >
4445 engines : Record < string , EngineOverrides >
46+ root_working_folder : string , // INTERNAL USE ONLY
4547 preserve_all_working_folders : boolean // INTERNAL USE ONLY
4648 custom_engine_plugin_modules : string [ ] // INTERNAL USE ONLY
4749}
@@ -53,6 +55,7 @@ export const DEFAULT_CONFIG: TopLevelConfig = {
5355 log_level : LogLevel . Debug ,
5456 rules : { } ,
5557 engines : { } ,
58+ root_working_folder : os . tmpdir ( ) , // INTERNAL USE ONLY
5659 preserve_all_working_folders : false , // INTERNAL USE ONLY
5760 custom_engine_plugin_modules : [ ] , // INTERNAL USE ONLY
5861} ;
@@ -139,7 +142,7 @@ export class CodeAnalyzerConfig {
139142 configRoot = ! rawConfig . config_root ? ( configRoot ?? process . cwd ( ) ) :
140143 validateAbsoluteFolder ( rawConfig . config_root , FIELDS . CONFIG_ROOT ) ;
141144 const configExtractor : engApi . ConfigValueExtractor = new engApi . ConfigValueExtractor ( rawConfig , '' , configRoot ) ;
142- configExtractor . addKeysThatBypassValidation ( [ FIELDS . CUSTOM_ENGINE_PLUGIN_MODULES , FIELDS . PRESERVE_ALL_WORKING_FOLDERS ] ) ; // Hidden fields bypass validation
145+ configExtractor . addKeysThatBypassValidation ( [ FIELDS . CUSTOM_ENGINE_PLUGIN_MODULES , FIELDS . PRESERVE_ALL_WORKING_FOLDERS , FIELDS . ROOT_WORKING_FOLDER ] ) ; // Hidden fields bypass validation
143146 configExtractor . validateContainsOnlySpecifiedKeys ( [ FIELDS . CONFIG_ROOT , FIELDS . LOG_FOLDER , FIELDS . LOG_LEVEL , FIELDS . RULES , FIELDS . ENGINES ] ) ;
144147 const config : TopLevelConfig = {
145148 config_root : configRoot ,
@@ -148,6 +151,7 @@ export class CodeAnalyzerConfig {
148151 custom_engine_plugin_modules : configExtractor . extractArray ( FIELDS . CUSTOM_ENGINE_PLUGIN_MODULES ,
149152 engApi . ValueValidator . validateString ,
150153 DEFAULT_CONFIG . custom_engine_plugin_modules ) ! ,
154+ root_working_folder : ! rawConfig . root_working_folder ? os . tmpdir ( ) : validateAbsoluteFolder ( rawConfig . root_working_folder , FIELDS . ROOT_WORKING_FOLDER ) ,
151155 preserve_all_working_folders : configExtractor . extractBoolean ( FIELDS . PRESERVE_ALL_WORKING_FOLDERS , DEFAULT_CONFIG . preserve_all_working_folders ) ! ,
152156 rules : extractRulesValue ( configExtractor ) ,
153157 engines : extractEnginesValue ( configExtractor )
@@ -239,6 +243,15 @@ export class CodeAnalyzerConfig {
239243 return this . config . preserve_all_working_folders ;
240244 }
241245
246+
247+ /**
248+ * Returns the absolute path to a folder that will serve as the root for all temporary working folders associated with
249+ * this execution.
250+ */
251+ public getRootWorkingFolder ( ) : string {
252+ return this . config . root_working_folder ;
253+ }
254+
242255 /**
243256 * Returns a {@link RuleOverrides} instance containing the user specified overrides for all rules associated with the specified engine
244257 * @param engineName name of the engine
0 commit comments