[Fix] install script: Don’t attempt to `cd` twice.

Fixes #1137.
Jordan Harband 2016-06-30 13:04:45 -07:00
parent a24ff3e605
commit cb4e010de7
1 changed files with 5 additions and 3 deletions

View File

@ -69,7 +69,7 @@ install_nvm_from_git() {
if [ -d "$INSTALL_DIR/.git" ]; then if [ -d "$INSTALL_DIR/.git" ]; then
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git" echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
printf "\r=> " 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 echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself." && exit 1
}) })
else else
@ -77,9 +77,11 @@ install_nvm_from_git() {
echo "=> Downloading nvm from git to '$INSTALL_DIR'" echo "=> Downloading nvm from git to '$INSTALL_DIR'"
printf "\r=> " printf "\r=> "
mkdir -p "$INSTALL_DIR" 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 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 [ ! -z "$(cd "$INSTALL_DIR" && git show-ref refs/heads/master)" ]; then
if git branch --quiet 2>/dev/null; then if git branch --quiet 2>/dev/null; then
cd "$INSTALL_DIR" && command git branch --quiet -D master >/dev/null 2>&1 cd "$INSTALL_DIR" && command git branch --quiet -D master >/dev/null 2>&1