Skip to content
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

Closed
wants to merge 1 commit into from
Closed

feat: Support match file with regular expression #33

wants to merge 1 commit into from

Conversation

axetroy
Copy link
Contributor

@axetroy axetroy commented Nov 28, 2017

Here is the default regExp

// Default pruned which match regular expression
var DefaultRegExp = []string{
	`\.___jb_tmp___$`,  // generate by JetBrains ide, to detect the file change
}

The default regExp is "\.___jb_tmp___$"
@@ -266,6 +284,15 @@ func dirStats(dir string) (*Stats, error) {
return &stats, err
}

// compile an regular expression array
Copy link
Contributor Author

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 {
Copy link
Contributor Author

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),
Copy link
Contributor Author

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

@axetroy
Copy link
Contributor Author

axetroy commented Nov 28, 2017

If merged. So we can remove test file happily

I wanna to remove all testfile name with xxxx.test.js

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
}

@axetroy
Copy link
Contributor Author

axetroy commented Dec 1, 2017

I I recommend to match file with regexp.

You can do more thing simply

for example: Remove Gulpfile.js

"Gulpfile.js",

"gulpfile.js",

There is no need to write it twice.

just need a patten (?i)Gulpfile.js$

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.

@tj
Copy link
Owner

tj commented Dec 1, 2017

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

@axetroy axetroy closed this Dec 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants