From 5806e40c1cc138a128aa463ad29a09d728fb57aa Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 1 Nov 2020 17:04:58 +0100 Subject: [PATCH] Add require_app_clone --- abra | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/abra b/abra index 2174943..a91e44f 100755 --- a/abra +++ b/abra @@ -306,6 +306,18 @@ require_stack() { fi } +require_app_clone() { + APP="$1" + APP_DIR="$ABRA_DIR/apps/$APP" + + if [ ! -d "$APP_DIR" ]; then + warning "'$APP' not found, fetching via git.." + if ! git clone "$GIT_URL/$APP.git" "$ABRA_DIR/apps/$APP"; then + error "Could not retrieve '$APP', this app doesn't exist?" + fi + fi +} + # FIXME 3wc: update or remove if [ -z "$ABRA_ENV" ] && [ -f .envrc ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then error "direnv is blocked, run direnv allow" @@ -431,6 +443,8 @@ sub_app_new (){ SERVER=$abra___server DOMAIN=$abra___domain + require_app_clone "$APP" + if [ -z "$SERVER" ]; then echo "Where would you like to put $APP?" @@ -450,16 +464,6 @@ sub_app_new (){ APP_DIR="$ABRA_DIR/apps/$APP" - if [ ! -d "$APP_DIR" ]; then - # FIXME 3wc: move to require_app_clone or something - warning "'$APP' not found, fetching via git.." - - if ! git clone "$GIT_URL/$APP.git" "$ABRA_DIR/apps/$APP"; then - error "Could not retrieve '$APP', this app doesn't exist?" - fi - - fi - if [ -z "$DOMAIN" ]; then read -rp "Domain name: " DOMAIN fi