ModClean / modclean

Remove unwanted files and directories from your node_modules folder
MIT License
400 stars 15 forks source link

Don't clean directories directly below any node_modules directory #14

Closed jorrit closed 6 years ago

jorrit commented 7 years ago

modclean removes the well-known history package. This problem is similar to the one @phips28 encountered in ModClean/modclean-patterns-default#1.

My suggestion is to not delete (unless empty) directories that are children of a node_modules directory. This catches all situations in which a package matches a pattern.

KyleRoss commented 6 years ago

@jorrit Since the newer versions of NPM already flattens the module structure (unless there is a version conflict), I'm not sure if your suggestion is going to fix the issue entirely. I may adjust the patterns to be a bit more specific to prevent the issue from happening.

An update will be coming hopefully today.

jorrit commented 6 years ago

My suggestion was not dependent on node_modules being flat or not. I meant to suggest that no directory directly below any node_modules folder should not be removed.

Let's say the directory structure is something like this:

node_modules
node_modules/history
node_modules/something
node_modules/something/history.md
node_modules/something/node_modules
node_modules/something/node_modules/history

Both history folders would be kept but history.md would be deleted.

KyleRoss commented 6 years ago

@jorrit Good point, still need to investigate this further. I believe the idea of having patterns that are different between directories and folders will help alleviate this situation going forward. It's something I'm going to look into building very soon.