Skip to content

Instantly share code, notes, and snippets.

@geek
Last active June 15, 2017 23:12
Show Gist options
  • Save geek/074251de4c9ba15307dbaa7d5d72ef4d to your computer and use it in GitHub Desktop.
Save geek/074251de4c9ba15307dbaa7d5d72ef4d to your computer and use it in GitHub Desktop.
Compare registry entry for module vs website
#!/bin/bash
# Example usage
# cat modules | while LINE='$\n' read -r LINE; do ./valid.sh $LINE; done;
MODULE=$1
if [ -z "$MODULE" ]; then
MODULE=$(tee);
fi
SITE=$(curl -s https://www.npmjs.com/package/${MODULE} | pup 'body > div.container.content > div.sidebar > ul:nth-child(3) > li:nth-child(2) > strong text{}')
REGISTRY=$(npm info ${MODULE} -j | json version)
if [ "$SITE" != "$REGISTRY" ]; then
echo "version mismatch for module: ${MODULE}";
exit 1;
fi
@geek
Copy link
Author

geek commented Jun 15, 2017

Requires npm install -g json and brew install https://raw.githubusercontent.com/EricChiang/pup/master/pup.rb

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment