Skip to content

Instantly share code, notes, and snippets.

@mjlescano
Last active September 17, 2018 17:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjlescano/442c3fd884a6adb3584beef97df28515 to your computer and use it in GitHub Desktop.
Save mjlescano/442c3fd884a6adb3584beef97df28515 to your computer and use it in GitHub Desktop.
Shell command to publish an npm package only if its needed
#!/bin/bash
CURRENT_VERSION=$(npm show $(node -pe 'require("./package.json").name') version)
NEXT_VERSION=$(node -pe 'require("./package.json").version')
[ "$CURRENT_VERSION" != "$NEXT_VERSION" ] && npm publish
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment