tj / node-prune

Remove unnecessary files from node_modules (.md, .ts, ...)
MIT License
4.4k stars 130 forks source link

feat: Support match file with regular expression #33

Closed axetroy closed 6 years ago

axetroy commented 6 years ago

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
}
axetroy commented 6 years ago

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 commented 6 years ago

I I recommend to match file with regexp.

You can do more thing simply

for example: Remove Gulpfile.js https://github.com/tj/node-prune/blob/1e61e90add69e4c3136d7d5b082bb4fc45f275f6/prune.go#L19 https://github.com/tj/node-prune/blob/1e61e90add69e4c3136d7d5b082bb4fc45f275f6/prune.go#L21

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 commented 6 years ago

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