Skip to content

Commit e544903

Browse files
author
Matt Pearson
committed
Set default vars after parsing args.
This lets `--config-file $FILE` override the script's defaults without having to explicitly set each var if that flag is specified.
1 parent df15333 commit e544903

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

deploy.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,6 @@ main() {
77
source .env
88
fi
99

10-
deploy_directory=${GIT_DEPLOY_DIR:-dist}
11-
deploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}
12-
13-
#if no user identity is already set in the current git environment, use this:
14-
default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
15-
default_email=${GIT_DEPLOY_EMAIL:-}
16-
17-
#repository to deploy to. must be readable and writable.
18-
repo=${GIT_DEPLOY_REPO:-origin}
19-
20-
#append commit hash to the end of message by default
21-
append_hash=true
22-
2310
# Parse arg flags
2411
while : ; do
2512
if [[ $1 = "-v" || $1 = "--verbose" ]]; then
@@ -41,6 +28,20 @@ main() {
4128
break
4229
fi
4330
done
31+
32+
# Set default options
33+
deploy_directory=${GIT_DEPLOY_DIR:-dist}
34+
deploy_branch=${GIT_DEPLOY_BRANCH:-gh-pages}
35+
36+
#if no user identity is already set in the current git environment, use this:
37+
default_username=${GIT_DEPLOY_USERNAME:-deploy.sh}
38+
default_email=${GIT_DEPLOY_EMAIL:-}
39+
40+
#repository to deploy to. must be readable and writable.
41+
repo=${GIT_DEPLOY_REPO:-origin}
42+
43+
#append commit hash to the end of message by default
44+
append_hash=true
4445

4546
enable_expanded_output
4647

0 commit comments

Comments
 (0)