Skip to content

Instantly share code, notes, and snippets.

@flesch
Created August 21, 2018 12:34
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 flesch/d9d40fa2d96ddda26e64900c87b942d7 to your computer and use it in GitHub Desktop.
Save flesch/d9d40fa2d96ddda26e64900c87b942d7 to your computer and use it in GitHub Desktop.
Git pre-commit hook to ensure the version in package.json has changed
#!/bin/bash
set -o nounset
if [ "$(git status -s | wc -l | bc)" -gt "0" ]; then
if [ "$(git diff --cached master -G '"version":' | wc -l | bc)" -eq "0" ]; then
echo -e "\033[31m✘\033[0m Aborting commit! \"package.json\" was not updated with a new version."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment