Created
January 17, 2025 03:08
-
-
Save chernjie/7025ca204c396b29dd0dc6c2073902d6 to your computer and use it in GitHub Desktop.
Remove redundant NPM modules
This file contains hidden or 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 | |
# @author CJ <[email protected]> | |
removeRedudantModules() { | |
jq < package.json '.'$1' | to_entries | map(.key)[]' -r | | |
while read i | |
do git grep -l $i | | |
wc -l | | |
xargs test 2 -ge && echo $i | |
done | | |
xargs npm remove | |
} | |
removeRedudantModules dependencies | |
removeRedudantModules devDependencies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment