From 8e42a60f68019df5356e57fb7776bac6e1584f65 Mon Sep 17 00:00:00 2001 From: baldo Date: Sat, 11 Jun 2016 20:13:38 +0200 Subject: [PATCH] Confirmation for publish.sh --- publish.sh | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/publish.sh b/publish.sh index 7d16d49..122da92 100755 --- a/publish.sh +++ b/publish.sh @@ -2,24 +2,53 @@ set -e +function confirm() { + msg="$1 [y/n] " + + echo -n $msg + + while read -n1 c; do + echo + + if [ "$c" == "y" ]; then + return 0 + fi + + if [ "$c" == "n" ]; then + return 1 + fi + + echo -n $msg + done +} + cd $(dirname $0) version=$(grep '^ *"version": *"[^"]*" *, *$' package.json | cut -d '"' -f4) +npm_tag=$1 if [ -z "$version" ]; then echo "Could not determine current version." exit 1 fi -echo "Current version: $version" +if [ -z "$npm_tag" ]; then + npm_tag=latest +fi + +echo "Current version: $version#$npm_tag" if [[ $version =~ 'SNAPSHOT' ]]; then echo "Will not publish SNAPSHOT version." exit 1 fi -./node_modules/.bin/grunt clean build +echo -cd dist -npm publish +if confirm "Continue publishing?"; then + ./node_modules/.bin/grunt clean build + + cd dist + npm publish -t $npm_tag +fi