Skip to content

Commit 29695ce

Browse files
Update install.sh
Clean up origin nvm directory before cloning nvm repository, fix #1212
1 parent 31c68ad commit 29695ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

install.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,19 @@ install_nvm_from_git() {
7575
exit 1
7676
}
7777
else
78+
echo "=> Cleanup old nvm dir '$INSTALL_DIR'"
79+
command rm -rf "$INSTALL_DIR/nvm-exec" "$INSTALL_DIR/nvm.sh"
7880
# Cloning to $INSTALL_DIR
7981
echo "=> Downloading nvm from git to '$INSTALL_DIR'"
8082
command printf "\r=> "
8183
mkdir -p "$INSTALL_DIR"
82-
command git clone "$(nvm_source)" "$INSTALL_DIR" || {
84+
command git init "$INSTALL_DIR"
85+
command git --git-dir="$INSTALL_DIR"/.git remote add origin "$(nvm_source)"
86+
command git --git-dir="$INSTALL_DIR"/.git pull origin master || {
8387
echo >&2 "Failed to clone nvm repo. Please report this!"
8488
exit 1
8589
}
90+
command git --git-dir="$INSTALL_DIR"/.git branch --set-upstream-to=origin/master master
8691
fi
8792
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" checkout --quiet "$(nvm_latest_version)"
8893
if [ ! -z "$(command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" show-ref refs/heads/master)" ]; then

0 commit comments

Comments
 (0)