Browse Source
Refactored ConfigFileFinder.cs (#786 )
* use of array initialization
* applied format and nicer if flow
* added both missing nit nit: prefer braces around ifs
* added compersion check for 0
Co-authored-by: John Luo <johluo@microsoft.com>
finitereality/replica-status-colors
Marvin Huber
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
11 additions and
11 deletions
src/Microsoft.Tye.Core/ConfigFileFinder.cs
@ -8,7 +8,7 @@ namespace Microsoft.Tye
{
public class ConfigFileFinder
{
private static readonly string [ ] FileFormats = new [ ] { "tye.yaml" , "tye.yml" , "docker-compose.yaml" , "docker-compose.yml" , "*.csproj" , "*.fsproj" , "*.sln" } ;
private static readonly string [ ] FileFormats = { "tye.yaml" , "tye.yml" , "docker-compose.yaml" , "docker-compose.yml" , "*.csproj" , "*.fsproj" , "*.sln" } ;
public static bool TryFindSupportedFile ( string directoryPath , out string? filePath , out string? errorMessage )
{
@ -16,19 +16,19 @@ namespace Microsoft.Tye
{
var files = Directory . GetFiles ( directoryPath , format ) ;
if ( files . Length = = 1 )
switch ( files . Length )
{
errorMessage = null ;
filePath = files [ 0 ] ;
return true ;
case 1 :
errorMessage = null ;
filePath = files [ 0 ] ;
return true ;
case 0 :
continue ;
}
if ( files . Length > 1 )
{
errorMessage = $"More than one matching file was found in directory '{directoryPath}'." ;
filePath = default ;
return false ;
}
errorMessage = $"More than one matching file was found in directory '{directoryPath}'." ;
filePath = default ;
return false ;
}
errorMessage = $"No project project file or solution was found in directory '{directoryPath}'." ;