-
Notifications
You must be signed in to change notification settings - Fork 130
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
feat: Support match file with regular expression #33
Conversation
The default regExp is "\.___jb_tmp___$"
@@ -266,6 +284,15 @@ func dirStats(dir string) (*Stats, error) { | |||
return &stats, err | |||
} | |||
|
|||
// compile an regular expression array |
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.
Add an function to compile the RegExp.
Just run once at program run
We do not need to compile patten every times
} | ||
|
||
|
||
for _, reg := range p.regexp { |
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.
Here to match file
exts: toMap(DefaultExtensions), | ||
dirs: toMap(DefaultDirectories), | ||
files: toMap(DefaultFiles), | ||
regexp: compileRegExp(DefaultRegExp), |
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.
Add an property to save the reg patten
If merged. So we can remove test file happily I wanna to remove all testfile name with and here is the patten // Default pruned which match regular expression
var DefaultRegExp = []string{
`\.___jb_tmp___$`, // generate by JetBrains ide, to detect the file change
`\.test\.(j|t)sx?$`, // remove all test file
} |
I I recommend to match file with regexp. You can do more thing simply for example: Remove Gulpfile.js Line 19 in 1e61e90
Line 21 in 1e61e90
There is no need to write it twice. just need a patten The regular expression shoud be the last step to check the file should be delete or not. I don't think we should worry about his performance. |
Go's regexps are pretty slow, curious how much of an impact it'll make, but I haven't noticed many cases where we'd need regexps |
Here is the default regExp