Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 1, 2014 17:38
Show Gist options
  • Save isaacs/6a1f350e0065b6d1d671 to your computer and use it in GitHub Desktop.
Save isaacs/6a1f350e0065b6d1d671 to your computer and use it in GitHub Desktop.
#!/bin/bash
# put this in your .bashrc or .bash_profile
# then run `squatter <username>`
# it'll print out the packages that probably are empty.
# use npm with the admin.npmrc file to remove them
squatter () {
local n1="$1"
local enc1="${n1// /%20}"
curl -vfs "http://registry.npmjs.org/-/by-user/$enc1" \
| json "$n1" \
| json -a \
| while read PKG; do
npm -q cache clean $PKG && \
files=$(
npm -q view $PKG dist.tarball \
| xargs curl -s \
| tar ztv \
| egrep -v 'package.json$' \
| egrep -v 'README\.md$' \
| egrep -v '\.npmignore$'
)
count=$(echo "$files" | wc -l)
if [ $count -lt 3 ]; then
echo ==== $PKG ====
echo "$files"
else
echo "$PKG has stuff in it"
fi
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment