mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-16 10:43:42 +00:00
Compare commits
4 Commits
3b8bcb663f
...
898c9c6fab
Author | SHA1 | Date | |
---|---|---|---|
![]() |
898c9c6fab | ||
![]() |
99352a64d2 | ||
![]() |
cf9beb7f86 | ||
![]() |
9222739d18 |
20
nvm.sh
20
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`'
|
||||
@ -478,6 +478,12 @@ nvm_tree_contains_path() {
|
||||
previous_pathdir="${node_path}"
|
||||
local pathdir
|
||||
pathdir=$(dirname "${previous_pathdir}")
|
||||
|
||||
# get real directory in case of symbolic links
|
||||
if [ -d "${pathdir-}" ]; then
|
||||
pathdir="$(nvm_cd -P "${pathdir}" && pwd)"
|
||||
fi
|
||||
|
||||
while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] &&
|
||||
[ "${pathdir}" != "${tree}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
|
||||
previous_pathdir="${pathdir}"
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
cleanup () {
|
||||
rm tmp3/tmp2
|
||||
rmdir tmp3
|
||||
rm tmp/node
|
||||
rmdir tmp
|
||||
rm tmp2/node
|
||||
@ -14,6 +16,8 @@ mkdir -p tmp
|
||||
touch tmp/node
|
||||
mkdir -p tmp2
|
||||
touch tmp2/node
|
||||
mkdir -p tmp3
|
||||
ln -s tmp2 tmp3/
|
||||
|
||||
[ "$(nvm_tree_contains_path 2>&1)" = "both the tree and the node path are required" ] || die 'incorrect error message with no args'
|
||||
[ "$(nvm_tree_contains_path > /dev/null 2>&1 ; echo $?)" = "2" ] || die 'incorrect error code with no args'
|
||||
@ -28,4 +32,6 @@ nvm_tree_contains_path tmp2 tmp2/node || die '"tmp2" should contain "tmp2/node"'
|
||||
|
||||
nvm_tree_contains_path tmp2 tmp/node && die '"tmp2" should not contain "tmp/node"'
|
||||
|
||||
nvm_tree_contains_path tmp2 tmp3 && die 'no idea'
|
||||
|
||||
cleanup
|
||||
|
Loading…
x
Reference in New Issue
Block a user