Created
August 22, 2016 11:00
-
-
Save meriadec/de283bf70c501e2ea3add734a9d3cf84 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
getCode () { | |
curl -s -I http://registry.npmjs.org/$1 | grep HTTP | awk {'print $2'} | |
} | |
isAvailable () { | |
res=$(getCode $1) | |
if [ "$res" == "404" ]; then | |
echo 1 | |
else | |
echo 0 | |
fi | |
} | |
printf "\n>> Querying npm registry...\n\n" | |
available=$(isAvailable $1) | |
if [ "$available" -eq 1 ]; then | |
printf "Package [\e[0;32m$1\e[0;0m] is available!\n" | |
else | |
printf "\e[0;31mPackage [$1] is not available :(\e[0;0m\n" | |
fi | |
echo '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment