Skip to content

Commit

Permalink
Fully parse arguments first in deploy (#1153)
Browse files Browse the repository at this point in the history
* Do not build sources when using --help

* Use variables for build/push if statements

* fix error message
  • Loading branch information
MasterOdin committed May 11, 2020
1 parent 391f3d8 commit 252a48b
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -73,8 +84,6 @@ parse_args() {
}

main() {
parse_args "$@"

enable_expanded_output

if ! git diff --exit-code --quiet --cached; then
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 252a48b

Please sign in to comment.