Skip to content

Instantly share code, notes, and snippets.

@bu1ka
Created March 20, 2018 22:05
Show Gist options
  • Save bu1ka/b3d1133e7c14f9d183176c36e2e33f1f to your computer and use it in GitHub Desktop.
Save bu1ka/b3d1133e7c14f9d183176c36e2e33f1f to your computer and use it in GitHub Desktop.
#!/bin/bash
is_package_json_at_git_index() {
package_json_changed=$(git diff --cached --name-only | grep -x package.json 2> /dev/null)
if [ "$package_json_changed" ];
then
return 0;
else
return 1;
fi
}
is_version_updated() {
version_changed=$(git diff --cached --unified=0 package.json 2> /dev/null | grep '^\+\s\{1,\}"version":')
if [ "$version_changed" ];
then
return 0;
else
return 1;
fi
}
is_changelog_updated() {
changelog_updated=$(git diff --cached CHANGELOG.md 2> /dev/null)
if [ "$changelog_updated" ];
then
return 0;
else
return 1;
fi
}
if is_package_json_at_git_index && is_version_updated && ! is_changelog_updated; then
echo "> YOU SHOULD UPDATE CHANGELOG!"
exit 1;
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment