Skip to content

Commit

Permalink
refactor: organized script into functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanneff committed Feb 10, 2017
1 parent 9ede660 commit b0640ea
Showing 1 changed file with 49 additions and 42 deletions.
91 changes: 49 additions & 42 deletions testbed/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,59 @@ usage() {
exit 1
}

if [[ "$#" -lt 1 ]]; then usage; fi
options() {
if [[ "$#" -lt 1 ]]; then usage; fi

for arg in "$@"; do
if ! [[ "$arg" =~ ^-. ]]; then usage; fi
done
for arg in "$@"; do
if ! [[ "$arg" =~ ^-. ]]; then usage; fi
done

while getopts ":hiadc" opt; do
case $opt in
h)
usage
;;
i)
run_ios=true
;;
a)
run_and=true
;;
d)
run_dep=true
;;
c)
run_cor=true
;;
*)
usage
;;
esac
done
while getopts ":hiadc" opt; do
case $opt in
h)
usage
;;
i)
run_ios=true
;;
a)
run_and=true
;;
d)
run_dep=true
;;
c)
run_cor=true
;;
*)
usage
;;
esac
done
}

main() {
# validate
gulp prod

# validate
gulp prod
# clean
if [[ "$run_cor" == "true" ]]; then npm install -g cordova; fi
if [[ "$run_dep" == "true" ]]; then npm uninstall mkpath node-version-compare plist xml2js; fi
rm -rf ../.installed
rm -rf ./plugins
rm -rf ./platforms

# clean
if [[ "$run_cor" == "true" ]]; then npm install -g cordova; fi
if [[ "$run_dep" == "true" ]]; then npm uninstall mkpath node-version-compare plist xml2js; fi
rm -rf ../.installed
rm -rf ./plugins
rm -rf ./platforms
# build (platforms added before plugin because before_plugin_install does not work on file reference)
if [[ "$run_ios" == "true" ]]; then cordova platform add ios; fi
if [[ "$run_and" == "true" ]]; then cordova platform add android; fi

# build (platforms added before plugin because before_plugin_install does not work on file reference)
if [[ "$run_ios" == "true" ]]; then cordova platform add ios; fi
if [[ "$run_and" == "true" ]]; then cordova platform add android; fi
# plugin
cordova plugin add ../

# plugin
cordova plugin add ../
# run
if [[ "$run_ios" == "true" ]]; then cordova build ios && open -a Xcode platforms/ios/Branch\ Testing.xcworkspace; fi
if [[ "$run_and" == "true" ]]; then cordova run android; fi
}

# run
if [[ "$run_ios" == "true" ]]; then cordova build ios && open -a Xcode platforms/ios/Branch\ Testing.xcworkspace; fi
if [[ "$run_and" == "true" ]]; then cordova run android; fi
options "$@"
main

0 comments on commit b0640ea

Please sign in to comment.