Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions DevProxy/Commands/ConfigCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ private enum ConfigFileFormat
private readonly IProxyConfiguration _proxyConfiguration;
private readonly HttpClient _httpClient;
private const string ConfigTemplatesFolder = "config-templates";
private static readonly string[] configFilePatterns = ["*.json", "*.yaml", "*.yml"];

public ConfigCommand(
HttpClient httpClient,
Expand Down Expand Up @@ -309,6 +310,8 @@ private async Task DownloadConfigAsync(string configId, OutputFormat outputForma
/// these file names. If there are no proxy configs, it'll return
/// an array of all the mock files. If there are no mocks, it'll return
/// an empty array indicating that there's no entry point.
/// Files in the .devproxy subfolder are listed before files in the
/// root folder.
/// </remarks>
/// <param name="configFolder">Full path to the folder with config files</param>
/// <returns>Array of files that can be used to start proxy with</returns>
Expand All @@ -318,11 +321,14 @@ private ProxyConfigInfo GetConfigInfo(string configFolder)

_logger.LogDebug("Getting list of config files in {ConfigFolder}...", configFolder);

// Get both JSON and YAML files
var jsonFiles = Directory.GetFiles(configFolder, "*.json");
var yamlFiles = Directory.GetFiles(configFolder, "*.yaml");
var ymlFiles = Directory.GetFiles(configFolder, "*.yml");
var allConfigFiles = jsonFiles.Concat(yamlFiles).Concat(ymlFiles).ToArray();
// Presets in the samples gallery keep their config in a .devproxy
// subfolder, so scan it first, followed by the root folder
var foldersToScan = new[] { Path.Combine(configFolder, ".devproxy"), configFolder }
.Where(Directory.Exists);
var allConfigFiles = foldersToScan
.SelectMany(folder => configFilePatterns
.SelectMany(pattern => Directory.GetFiles(folder, pattern)))
.ToArray();

if (allConfigFiles.Length == 0)
{
Expand Down
Loading