Created
January 12, 2021 03:50
-
-
Save Boshen/2e4b165e5632e424fb9cbbbe09fc505e to your computer and use it in GitHub Desktop.
prune node_modules
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
if [ -n "$1" ]; then WD="$PWD/$1"; else WD=$PWD; fi | |
run () { | |
(cd "$WD" && eval "$@") | sed 's/[[:space:]].//g' | |
} | |
stats() { | |
SIZE=$(run du -hs) | |
FILES=$(run find node_modules/ -type f \| wc -l) | |
echo "$1: $SIZE ($FILES files)" | |
} | |
stats "Before" | |
# Common unnecessary files | |
run find . -type d -name node_modules -prune -exec find {} -type f \\\( \ | |
-iname Makefile -or \ | |
-iname README -or \ | |
-iname README.md -or \ | |
-iname CHANGELOG -or \ | |
-iname CHANGELOG.md -or \ | |
-name .editorconfig -or \ | |
-name .gitmodules -or \ | |
-name .gitattributes -or \ | |
-name robot.html -or \ | |
-name .lint -or \ | |
-name .lintignore -or \ | |
-iname Gulpfile.js -or \ | |
-iname Gruntfile.js -or \ | |
-name .tern-project -or \ | |
-name .gitattributes -or \ | |
-name .editorconfig -or \ | |
-name .eslintrc -or \ | |
-name .jshintrc -or \ | |
-name .npmignore -or \ | |
-name .flowconfig -or \ | |
-name .documentup.json -or \ | |
-name .yarn-metadata.json -or \ | |
-name .travis.yml -or \ | |
-name thumbs.db -or \ | |
-name .tern-port -or \ | |
-name .ds_store -or \ | |
-name desktop.ini -or \ | |
-name npm-debug.log -or \ | |
-name .npmrc -or \ | |
-iname LICENSE.txt -or \ | |
-iname LICENSE.md -or \ | |
-iname LICENSE-MIT -or \ | |
-iname LICENSE-MIT.txt -or \ | |
-iname LICENSE.BSD -or \ | |
-iname LICENSE-BSD -or \ | |
-iname LICENSE-jsbn -or \ | |
-iname LICENSE -or \ | |
-iname AUTHORS -or \ | |
-iname CHANGES -or \ | |
-iname CONTRIBUTORS -or \ | |
-name .yarn-integrity -or \ | |
-name builderror.log -or \ | |
-name "*.md" -or \ | |
-name "*.sln" -or \ | |
-name "*.obj" -or \ | |
-name "*.gypi" -or \ | |
-name "*.vcxproj" -or \ | |
-name "*.vcxproj.filters" -or \ | |
-name '*.ts' -or \ | |
-name '*.d.ts' -or \ | |
-name '*.flow' -or \ | |
-name "*.jst" -or \ | |
-name "*.map" -or \ | |
-name "*.coffee" \ | |
\\\) -print0 \\\; \| xargs -0 rm -rf | |
# Common unnecessary folders | |
run find . -type d -name node_modules -prune -exec find {} -type d \\\( \ | |
-name __tests__ -or \ | |
-name tests -or \ | |
-name powered-test -or \ | |
-name docs -or \ | |
-name doc -or \ | |
-name website -or \ | |
-name images -or \ | |
-name assets -or \ | |
-name example -or \ | |
-name examples -or \ | |
-name coverage -or \ | |
-name node-gyp -or \ | |
-name node-pre-gyp -or \ | |
-name gyp -or \ | |
-name .nyc_output \ | |
\\\) -print0 \\\; \| xargs -0 rm -rf | |
# Remove unused huge folders | |
rm -rf node_modules/typescript \ | |
node_modules/rxjs/src/ \ | |
node_modules/rxjs/bundles/ \ | |
node_modules/rxjs/_esm5/ \ | |
node_modules/rxjs/_esm2015/ \ | |
node_modules/date-fns/esm/ \ | |
node_modules/punycode2/test/ | |
stats "After" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment