Skip to content

Commit b5985b1

Browse files
[New] Speedup process to install nvm from git by dropping commit history
1 parent 0a95e77 commit b5985b1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

install.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ install_nvm_from_git() {
8484
if [ -d "$INSTALL_DIR/.git" ]; then
8585
echo "=> nvm is already installed in $INSTALL_DIR, trying to update using git"
8686
command printf "\r=> "
87-
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch 2> /dev/null || {
87+
command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$(nvm_latest_version)" --depth=1 2> /dev/null || {
8888
echo >&2 "Failed to update nvm, run 'git fetch' in $INSTALL_DIR yourself."
8989
exit 1
9090
}
@@ -103,12 +103,12 @@ install_nvm_from_git() {
103103
echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
104104
exit 2
105105
}
106-
command git --git-dir="${INSTALL_DIR}/.git" fetch origin --tags || {
106+
command git --git-dir="${INSTALL_DIR}/.git" fetch origin tag "$(nvm_latest_version)" --depth=1 || {
107107
echo >&2 'Failed to fetch origin with tags. Please report this!'
108108
exit 2
109109
}
110110
else
111-
command git clone "$(nvm_source)" "${INSTALL_DIR}" || {
111+
command git clone "$(nvm_source)" -b "$(nvm_latest_version)" --depth=1 "${INSTALL_DIR}" || {
112112
echo >&2 'Failed to clone nvm repo. Please report this!'
113113
exit 2
114114
}

0 commit comments

Comments
 (0)