-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
When attempting to use command line tool on a directory with a . in the final folder level, the input is incorrectly assumed to be a file. For instance, C:/A.Directory is assumed to be a file, even if it's a folder name.
The root cause is a result of using a regex to determine filenames at:
| public static bool EndsWithFileExtension(this string text) | |
| => Regex.IsMatch(text, @"\.\w+$"); |
I'd propose ditching the use of that extension method and just checking both file/directory existence at the same time.
So change the existing:
CSharpToTypeScript/src/CSharpToTypeScript.CLITool/Validation/InputExists.cs
Lines 20 to 27 in f36b19e
| else if (command.Input.EndsWithFileExtension() && !File.Exists(command.Input)) | |
| { | |
| return new ValidationResult($"The file path '{command.Input}' does not exist."); | |
| } | |
| else if (!command.Input.EndsWithFileExtension() && !Directory.Exists(command.Input)) | |
| { | |
| return new ValidationResult($"The directory path '{command.Input}' does not exist."); | |
| } |
to simply:
else if (!File.Exists(command.Input) && !Directory.Exists(command.Input))
{
return new ValidationResult($"The file or directory path '{command.Input}' does not exist.");
}Might resolve #44?
Metadata
Metadata
Assignees
Labels
No labels