Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # It goes something like: ls the packages, grep the names, make them unique,
- # find duplicates, sort by version, remove old versions.
- #
- # See that gsort (macOS)? that's $ brew install coreutils
- ls $(yarn cache dir) | grep -oE "^(npm-[a-z-]+)" | uniq | while read -r i; do ls -1d "$i"* | grep -cE "$i\d" | { read -r c; if (( c > 1 )); then ls -1d "$i"* | grep -E "$i\d" | gsort -Vr | tail -n +2 | xargs rm -r; fi }; done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement