CSharpToTypeScript icon indicating copy to clipboard operation
CSharpToTypeScript copied to clipboard

CLI tool improperly recognizing directories

Open GravlLift opened this issue 3 years ago • 0 comments

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: https://github.com/AdrianWilczynski/CSharpToTypeScript/blob/f36b19e402047890912224d95e90088f01d07692/src/CSharpToTypeScript.CLITool/Utilities/FileSystem.cs#L18-L19

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: https://github.com/AdrianWilczynski/CSharpToTypeScript/blob/f36b19e402047890912224d95e90088f01d07692/src/CSharpToTypeScript.CLITool/Validation/InputExists.cs#L20-L27

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?

GravlLift avatar Jul 13 '22 17:07 GravlLift