mirror of
https://github.com/nvm-sh/nvm.git
synced 2026-02-06 18:02:50 +08:00
Compare commits
5 Commits
v0.40.2
...
35020b4b21
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
35020b4b21 | ||
|
|
99352a64d2 | ||
|
|
22b4bf3fe9 | ||
|
|
e82ea42706 | ||
|
|
c54ca7cfa7 |
15
install.sh
15
install.sh
@@ -139,6 +139,9 @@ install_nvm_from_git() {
|
||||
fi
|
||||
fi
|
||||
|
||||
local remote
|
||||
remote="$(git config --global clone.defaultRemoteName || true)"
|
||||
remote="${remote:-origin}"
|
||||
local fetch_error
|
||||
if [ -d "$INSTALL_DIR/.git" ]; then
|
||||
# Updating repo
|
||||
@@ -146,7 +149,7 @@ install_nvm_from_git() {
|
||||
command printf '\r=> '
|
||||
fetch_error="Failed to update nvm with $NVM_VERSION, run 'git fetch' in $INSTALL_DIR yourself."
|
||||
else
|
||||
fetch_error="Failed to fetch origin with $NVM_VERSION. Please report this!"
|
||||
fetch_error="Failed to fetch ${remote} with ${NVM_VERSION}. Please report this!"
|
||||
nvm_echo "=> Downloading nvm from git to '$INSTALL_DIR'"
|
||||
command printf '\r=> '
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
@@ -156,9 +159,9 @@ install_nvm_from_git() {
|
||||
nvm_echo >&2 'Failed to initialize nvm repo. Please report this!'
|
||||
exit 2
|
||||
}
|
||||
command git --git-dir="${INSTALL_DIR}/.git" remote add origin "$(nvm_source)" 2> /dev/null \
|
||||
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url origin "$(nvm_source)" || {
|
||||
nvm_echo >&2 'Failed to add remote "origin" (or set the URL). Please report this!'
|
||||
command git --git-dir="${INSTALL_DIR}/.git" remote add "$remote" "$(nvm_source)" 2> /dev/null \
|
||||
|| command git --git-dir="${INSTALL_DIR}/.git" remote set-url "$remote" "$(nvm_source)" || {
|
||||
nvm_echo >&2 'Failed to add remote "'"$remote"'" (or set the URL). Please report this!'
|
||||
exit 2
|
||||
}
|
||||
else
|
||||
@@ -170,10 +173,10 @@ install_nvm_from_git() {
|
||||
fi
|
||||
fi
|
||||
# Try to fetch tag
|
||||
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin tag "$NVM_VERSION" --depth=1 2>/dev/null; then
|
||||
if command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch "$remote" tag "$NVM_VERSION" --depth=1 2>/dev/null; then
|
||||
:
|
||||
# Fetch given version
|
||||
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch origin "$NVM_VERSION" --depth=1; then
|
||||
elif ! command git --git-dir="$INSTALL_DIR"/.git --work-tree="$INSTALL_DIR" fetch "$remote" "$NVM_VERSION" --depth=1; then
|
||||
nvm_echo >&2 "$fetch_error"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
14
nvm.sh
14
nvm.sh
@@ -356,19 +356,19 @@ nvm_install_latest_npm() {
|
||||
if [ $NVM_IS_19_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.5.0; then
|
||||
NVM_IS_20_5_OR_ABOVE=1
|
||||
fi
|
||||
local NVM_IS_20_17_or_ABOVE
|
||||
NVM_IS_20_17_or_ABOVE=0
|
||||
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater 20.17.0 "${NODE_VERSION}"; then
|
||||
NVM_IS_20_17_or_ABOVE=1
|
||||
local NVM_IS_20_17_OR_ABOVE
|
||||
NVM_IS_20_17_OR_ABOVE=0
|
||||
if [ $NVM_IS_20_5_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 20.17.0; then
|
||||
NVM_IS_20_17_OR_ABOVE=1
|
||||
fi
|
||||
local NVM_IS_21_OR_ABOVE
|
||||
NVM_IS_21_OR_ABOVE=0
|
||||
if [ $NVM_IS_20_17_or_ABOVE -eq 1 ] && nvm_version_greater 21.0.0 "${NODE_VERSION}"; then
|
||||
if [ $NVM_IS_20_17_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 21.0.0; then
|
||||
NVM_IS_21_OR_ABOVE=1
|
||||
fi
|
||||
local NVM_IS_22_9_OR_ABOVE
|
||||
NVM_IS_22_9_OR_ABOVE=0
|
||||
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater 22.9.0 "${NODE_VERSION}"; then
|
||||
if [ $NVM_IS_21_OR_ABOVE -eq 1 ] && nvm_version_greater_than_or_equal_to "${NODE_VERSION}" 22.9.0; then
|
||||
NVM_IS_22_9_OR_ABOVE=1
|
||||
fi
|
||||
|
||||
@@ -420,7 +420,7 @@ nvm_install_latest_npm() {
|
||||
nvm_echo '* `npm` `v9.x` is the last version that works on `node` `< v18.17`, `v19`, or `v20.0` - `v20.4`'
|
||||
$NVM_NPM_CMD install -g npm@9
|
||||
elif \
|
||||
[ $NVM_IS_20_17_or_ABOVE -eq 0 ] \
|
||||
[ $NVM_IS_20_17_OR_ABOVE -eq 0 ] \
|
||||
|| { [ $NVM_IS_21_OR_ABOVE -eq 1 ] && [ $NVM_IS_22_9_OR_ABOVE -eq 0 ]; } \
|
||||
; then
|
||||
nvm_echo '* `npm` `v10.x` is the last version that works on `node` `< v20.17`, `v21`, or `v22.0` - `v22.8`'
|
||||
|
||||
Reference in New Issue
Block a user