From cb4e010de77fd02e45ed9e0ab35937e9e9dbe5f9 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 30 Jun 2016 13:04:45 -0700 Subject: [PATCH] =?UTF-8?q?[Fix]=20install=20script:=20Don=E2=80=99t=20att?= =?UTF-8?q?empt=20to=20`cd`=20twice.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #1137. --- install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 9b8fd01..f12882c 100755 --- a/install.sh +++ b/install.sh @@ -69,7 +69,7 @@ install_nvm_from_git() { if [ -d "$INSTALL_DIR/.git" ]; then echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" printf "\r=> " - cd "$INSTALL_DIR" && (git fetch 2> /dev/null || { + cd "$INSTALL_DIR" && (command git fetch 2> /dev/null || { echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." && exit 1 }) else @@ -77,9 +77,11 @@ install_nvm_from_git() { echo "=> Downloading nvm from git to '$INSTALL_DIR'" printf "\r=> " mkdir -p "$INSTALL_DIR" - git clone "$(nvm_source)" "$INSTALL_DIR" + command git clone "$(nvm_source)" "$INSTALL_DIR" \ + || echo >&2 "Failed to clone nvm repo. Please report this!" && exit 1 + cd "$INSTALL_DIR" fi - cd "$INSTALL_DIR" && command git checkout --quiet "$(nvm_latest_version)" + command git checkout --quiet "$(nvm_latest_version)" if [ ! -z "$(cd "$INSTALL_DIR" && git show-ref refs/heads/master)" ]; then if git branch --quiet 2>/dev/null; then cd "$INSTALL_DIR" && command git branch --quiet -D master >/dev/null 2>&1