Skip to content

Instantly share code, notes, and snippets.

@iboss-ptk
Last active January 8, 2020 15:12
Show Gist options
  • Select an option

  • Save iboss-ptk/ebe6f4330d627fe74d2e8f5bf702963e to your computer and use it in GitHub Desktop.

Select an option

Save iboss-ptk/ebe6f4330d627fe74d2e8f5bf702963e to your computer and use it in GitHub Desktop.
#!/bin/bash
# usage ./js?.sh <word>
WORD=$1
STATUS_CODE=$(curl -s -o /dev/null -I -w "%{http_code}" "https://www.npmjs.com/package/$WORD")
if [ "$STATUS_CODE" == 200 ]
then
echo "Found \"$WORD\" js package. DRINK!"
elif [ "$STATUS_CODE" == 404 ]
then
echo "\"$WORD\", js package not found."
exit 1
else
echo "failed with status code: $STATUS_CODE"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment