c81804825c03e563ab748aae84c3f63458961208

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

fix(installer): fix removal of OMZ directory on failure

When the `git init` call fails, the directory is not created,
so the rm command fails with a not found error. This change
checks whether the directory exists before deleting it.

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index 7953ad1120aa3df83adeae391706a59ed73e1c7f..93608eb7c2b0b082990b6fb65738ff6d5d6f658d 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -283,7 +283,7 @@ setup_ohmyzsh() {
 6   && git remote add origin "$REMOTE" \
 7   && git fetch --depth=1 origin \
 8   && git checkout -b "$BRANCH" "origin/$BRANCH" || {
 9-    rm -rf "$ZSH"
10+    [ ! -d "$ZSH" ] || rm -rf "$ZSH" 2>/dev/null
11     fmt_error "git clone of oh-my-zsh repo failed"
12     exit 1
13   }