Last active
October 1, 2022 02:47
-
-
Save themanifold/2cd180c2ec4d49dd61f5da8e25481c42 to your computer and use it in GitHub Desktop.
Pruning useless node_modules with bash userland tools (find etc)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
find node_modules \( -name '__tests__' -o \ | |
-name 'test' -o \ | |
-name 'tests' -o \ | |
-name 'powered-test' -o \ | |
-name 'docs' -o \ | |
-name 'doc' -o \ | |
-name '.idea' -o \ | |
-name '.vscode' -o \ | |
-name 'website' -o \ | |
-name 'images' -o \ | |
-name 'assets' -o \ | |
-name 'example' -o \ | |
-name 'examples' -o \ | |
-name 'coverage'-o \ | |
-name '.nyc_output' -o \ | |
-name "*.md" -o \ | |
-name "*.ts" -o \ | |
-name "*.jst" -o \ | |
-name "*.coffee" -o \ | |
-name "*.tgz" \) -exec rm -rf {} \; |
I'd modified this like that
find ... | grep -v "/dist" | xargs rm -rf
you shouldn't be removing anything inside dist folder, it will break some packages, most notably ones that generate HTML's and stuff. For me it was mochawesome-report-generator (which contains "assets" in its "dist" folder) and some shitty react datepicker module, I believe
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@themanifold, please replace
| xargs rm -rf
into--delete
.