tj / node-prune

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

Feature request: keep certain directories #63

Open tomjakubowski opened 4 years ago

tomjakubowski commented 4 years ago

Some NPM modules actually include Javascript modules named docs/..., and node-prune breaks these because docs/ are removed per the default rules. It would be nice, then, to mark a given directory to not be removed according to node-prune's rules:

$ node-prune --except node_modules/googleapis/../docs/
tobias-klein commented 3 years ago

Has there been any consideration to implement this feature? I would also appreciate it. In case of Ezra Project, I needed to remove one entry from the list of directories pruned. And for this simple patch I had to fork node-prune.

tobias-klein commented 3 years ago

I just noticed that a new release has actually been tagged in May this year, mentioning --include and --exclude flags. This is not mentioned in the README file, though. Is there a reason why no release is available?

duniul commented 3 years ago

I wrote clean-modules to get around this, it's about as fast as node-prune and supports proper globbing by file paths.

To achieve the question from the OP you can e.g. do:

clean-modules --exclude **/googleapis/**/docs

--include and --exclude works for node-prune, but it only seems to validate the globs against file names.