-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ignored directories option and bug fix. #93
Conversation
Thanks, I will check it out. |
}); | ||
AddOption(new Option(new[] { "--ignore-directories" }, "Ignore directories when searching files. Example: -ignore-directories Folder1,Folder2") | ||
{ | ||
Argument = new Argument<string>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's better to use string[]
type instead of a single string, so that we need not to worry about the format of the option.(CLI library will check it automatically)
See:
AddArgument(new Argument<string[]>("method-names") {Description = "The method names"}); |
|
||
var ignored = ignoredDirectories? | ||
.Split(new[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries) | ||
.Select(x => Path.Combine(baseDirectory, x)).ToArray() ?? Array.Empty<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the ignored directories have to be directly under the BaseDirectory
?
Can they be arbitrary depth?
For example, If I use --ignore-directories IgnoreDir
, can the directory C:\BaseDirectory\aspnet-core\src\MyAbp.Domain\*IgnoreDir*
be ignored?
|
||
TemplateType templateType; | ||
if (Directory.EnumerateFiles(baseDirectory, "*.DbMigrator.csproj", SearchOption.AllDirectories).Any()) | ||
if (Directory.EnumerateFiles(baseDirectory, "*.DbMigrator.csproj", SearchOption.AllDirectories).Any(x => !ignored.Any(x.StartsWith))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this usage repeats for many times, I think it's better to extract an extension method, e.g:
EnumerateFiles(this Directory directory, ... , string[] ignoreDirectories)
step => | ||
.Then<IfElse>( | ||
ie => ie.ConditionExpression = new JavaScriptExpression<bool> | ||
("ProjectInfo.UiFramework == 1"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use explicit enum instead of magic number, like:
($"ProjectInfo.UiFramework == {UiFramework.RazorPages.ToString("D")}")
}) | ||
.Then<IfElse>( | ||
ie => ie.ConditionExpression = new JavaScriptExpression<bool> | ||
("ProjectInfo.UiFramework == 0"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with previous comment.
Wow, it becomes a huge PR. |
--ignored-directories
option: ignore directories when searching files.