@@ -6,24 +6,26 @@ import (
66 "path/filepath"
77)
88
9- // ConfigFileExists checks if a specific configuration file exists in the .codacy/tools-configs/
9+ // ConfigFileExists checks if any of the specified configuration files exist in the .codacy/tools-configs/
1010// or on the root of the repository directory.
1111//
1212// Parameters:
1313// - conf: The configuration object containing the tools config directory
14- // - fileName: The configuration file name to check for
14+ // - fileNames: A list of configuration file names to check for
1515//
1616// Returns:
17- // - string: The relative path to the configuration file (for cmd args)
18- // - bool: True if the file exists, false otherwise
19- func ConfigFileExists (conf config.ConfigType , fileName string ) (string , bool ) {
20- generatedConfigFile := filepath .Join (conf .ToolsConfigDirectory (), fileName )
21- existingConfigFile := filepath .Join (conf .RepositoryDirectory (), fileName )
17+ // - string: The relative path to the first configuration file found (for cmd args)
18+ // - bool: True if any file exists, false otherwise
19+ func ConfigFileExists (conf config.ConfigType , fileNames ... string ) (string , bool ) {
20+ for _ , fileName := range fileNames {
21+ generatedConfigFile := filepath .Join (conf .ToolsConfigDirectory (), fileName )
22+ existingConfigFile := filepath .Join (conf .RepositoryDirectory (), fileName )
2223
23- if _ , err := os .Stat (generatedConfigFile ); err == nil {
24- return generatedConfigFile , true
25- } else if _ , err := os .Stat (existingConfigFile ); err == nil {
26- return existingConfigFile , true
24+ if _ , err := os .Stat (generatedConfigFile ); err == nil {
25+ return generatedConfigFile , true
26+ } else if _ , err := os .Stat (existingConfigFile ); err == nil {
27+ return existingConfigFile , true
28+ }
2729 }
2830
2931 return "" , false
0 commit comments