From 1cb5f632fe73f707a13fc0a78450955e02da6715 Mon Sep 17 00:00:00 2001 From: Ethan Neff Date: Fri, 10 Feb 2017 14:32:57 -0800 Subject: [PATCH] feat: added arguments to testbed init --- testbed/rebuild.sh | 66 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/testbed/rebuild.sh b/testbed/rebuild.sh index 8a003f34..f4a41f53 100755 --- a/testbed/rebuild.sh +++ b/testbed/rebuild.sh @@ -1,25 +1,69 @@ #!/bin/bash +# properties +run_ios=false +run_and=false +run_dep=false +run_cor=false + +# options +usage() { + printf "\n invalid usage" + printf "\n ./rebuild.sh -h -> help" + printf "\n ./rebuild.sh -i -> build ios" + printf "\n ./rebuild.sh -a -> build android" + printf "\n ./rebuild.sh -d -> reset node dependencies" + printf "\n ./rebuild.sh -c -> reset cordova plugin" + printf "\n" + exit 1 +} + +if [[ "$#" < 1 ]]; then usage; fi + +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 + # validate gulp prod # clean -# npm install -g cordova -npm uninstall mkpath node-version-compare plist xml2js +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 -# add platforms before plugin because before_plugin_install does not work on file reference -# cordova platform add android -cordova platform add ios +# 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 ../ -# ios -cordova run ios --device -#open -a Xcode platforms/ios/Branch\ Testing.xcworkspace - -# android -# cordova run android \ No newline at end of file +# 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