From 252a48b31e7d34b4099b590bead3ea021a65cff6 Mon Sep 17 00:00:00 2001 From: Matthew Peveler Date: Tue, 5 Nov 2019 10:39:26 -0300 Subject: [PATCH] Fully parse arguments first in deploy (#1153) * Do not build sources when using --help * Use variables for build/push if statements * fix error message --- deploy.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/deploy.sh b/deploy.sh index f122ba7ce62..f872d23f713 100755 --- a/deploy.sh +++ b/deploy.sh @@ -36,7 +36,7 @@ parse_args() { while : ; do if [[ $1 = "-h" || $1 = "--help" ]]; then echo "$help_message" - return 0 + exit 0 elif [[ $1 = "-v" || $1 = "--verbose" ]]; then verbose=true shift @@ -49,11 +49,22 @@ parse_args() { elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then GIT_DEPLOY_APPEND_HASH=false shift + elif [[ $1 = "--source-only" ]]; then + source_only=true + shift + elif [[ $1 = "--push-only" ]]; then + push_only=true + shift else break fi done + if [ ${source_only} ] && [ ${push_only} ]; then + >&2 echo "You can only specify one of --source-only or --push-only" + exit 1 + fi + # Set internal option vars from the environment and arg flags. All internal # vars should be declared here, with sane defaults if applicable. @@ -73,8 +84,6 @@ parse_args() { } main() { - parse_args "$@" - enable_expanded_output if ! git diff --exit-code --quiet --cached; then @@ -205,9 +214,11 @@ sanitize() { "$@" 2> >(filter 1>&2) | filter } -if [[ $1 = --source-only ]]; then +parse_args "$@" + +if [[ ${source_only} ]]; then run_build -elif [[ $1 = --push-only ]]; then +elif [[ ${push_only} ]]; then main "$@" else run_build