Created
June 7, 2017 14:40
-
-
Save goliatone/dcb7809b4c436c7999f1ddd8a1f71550 to your computer and use it in GitHub Desktop.
Simple NPM publish script
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 | |
| function major { | |
| npm version major && npm publish && npm version patch && git push --tags && git push origin master | |
| } | |
| function minor { | |
| npm version minor && npm publish && npm version patch && git push --tags && git push origin master | |
| } | |
| function patch { | |
| npm version patch && npm publish && git push --tags && git push origin master | |
| } | |
| function help { | |
| echo "$0 [<major|minor|patch>] -m" | |
| echo "Publishes package to npm and git." | |
| echo "\t1 major" | |
| echo "\t4 minor" | |
| echo "\t5 patch" | |
| } | |
| if [ "$0" == "help" ]; then | |
| help | |
| elif output=$(git status --untracked-files=no --porcelain) && [ -z "$output" ]; then | |
| # Working directory clean | |
| TIMEFORMAT="Published in %3lR" | |
| time ${@:-help} | |
| else | |
| red=`tput setaf 1` | |
| reset=`tput sgr0` | |
| echo "\t${red}Git working directory not clean." | |
| echo "\tCommit your changes and try again.${reset}" | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment