-
-
Save parro-it/c8ea175b8e68e2b74a09f4dc16113f5d to your computer and use it in GitHub Desktop.
npm publish command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
upgrade=$1 | |
COLOR_RED='\e[0;31m' | |
COLOR_NC='\e[0m' # No Color | |
case $upgrade in | |
mi*) ver=minor;; | |
ma*) ver=major;; | |
pa*) ver=patch;; | |
*) echo 'Usage: pub [kind]'; exit 2;; | |
esac | |
if [ `git diff-index HEAD | wc -l` -ne 0 ]; then | |
printf "${COLOR_RED}Git working directory not clean.${COLOR_NC}" | |
exit 3 | |
fi | |
if [ -f package-lock.json ]; then | |
rm package-lock.json | |
fi | |
alias get-version="node -p \"require('./package.json').version\"" | |
old_version=`get-version` | |
if ! npm version $ver > /dev/null ; then | |
exit 4 | |
fi | |
new_version=`get-version` | |
echo "🤖 - Publishing $ver semver upgrade ($old_version --> $new_version)." | |
npm publish | |
git push --follow-tags | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment