Skip to content

Instantly share code, notes, and snippets.

@Abdelkrim
Created February 20, 2020 13:20
Show Gist options
  • Save Abdelkrim/8b0c5bfa0ed8a6c651d71ec5f920e41d to your computer and use it in GitHub Desktop.
Save Abdelkrim/8b0c5bfa0ed8a6c651d71ec5f920e41d to your computer and use it in GitHub Desktop.
standard-version :
#!/bin/sh
# INSTALLATION
#
# COPY THE FILE commit-msg INTO .git/hooks/commit-msg
# COPY THE FILE package.json INTO THE ROOT OF YOUR PROJECT
# MODIFY THE FILE package.json TO MATCH PROJECT DESCRIPTION
# RUN npm install to install standard-version locally
# CODE, COMMIT YOUR CODE
# RUN 'npm run patch', 'npm run minor' or 'npm run major' TO GENERATE THE VERSION NUMBER and THE CHANGELOG FILE
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".
# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
# This example catches duplicate Signed-off-by lines.
test "" = "$(grep '^Signed-off-by: ' "$1" |
sort | uniq -c | sed -e '/^[ ]*1[ ]/d')" || {
echo >&2 Duplicate Signed-off-by lines.
exit 1
}
echo "" >&2
echo "1." >&2
echo "npm run patch" >&2
echo "" >&2
echo "npm run minor" >&2
echo "" >&2
echo "npm run major" >&2
echo "2." >&2
echo "npm run push" >&2
echo "" >&2
echo "" >&2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment