@@ -205,18 +205,16 @@ nvm_rc_version() {
205
205
export NVM_RC_VERSION=' '
206
206
local NVMRC_PATH
207
207
NVMRC_PATH=" $( nvm_find_nvmrc) "
208
- if [ -e " ${NVMRC_PATH} " ]; then
209
- read -r NVM_RC_VERSION < " ${NVMRC_PATH} " || printf ' '
210
- if [ -n " ${NVM_RC_VERSION} " ]; then
211
- nvm_echo " Found '${NVMRC_PATH} ' with version <${NVM_RC_VERSION} >"
212
- else
213
- nvm_err " Warning: empty .nvmrc file found at \" ${NVMRC_PATH} \" "
214
- return 2
215
- fi
216
- else
208
+ if [ ! -e " ${NVMRC_PATH} " ]; then
217
209
nvm_err " No .nvmrc file found"
218
210
return 1
219
211
fi
212
+ read -r NVM_RC_VERSION < " ${NVMRC_PATH} " || printf ' '
213
+ if [ ! -n " ${NVM_RC_VERSION} " ]; then
214
+ nvm_err " Warning: empty .nvmrc file found at \" ${NVMRC_PATH} \" "
215
+ return 2
216
+ fi
217
+ nvm_echo " Found '${NVMRC_PATH} ' with version <${NVM_RC_VERSION} >"
220
218
}
221
219
222
220
nvm_clang_version () {
@@ -341,9 +339,8 @@ nvm_version() {
341
339
if [ -z " ${VERSION} " ] || [ " _${VERSION} " = " _N/A" ]; then
342
340
nvm_echo " N/A"
343
341
return 3;
344
- else
345
- nvm_echo " ${VERSION} "
346
342
fi
343
+ nvm_echo " ${VERSION} "
347
344
}
348
345
349
346
nvm_remote_version () {
@@ -1261,10 +1258,9 @@ nvm_checksum() {
1261
1258
elif [ -z " ${2-} " ]; then
1262
1259
nvm_echo ' Checksums empty' # missing in raspberry pi binary
1263
1260
return
1264
- else
1265
- nvm_err ' Checksums do not match.'
1266
- return 1
1267
1261
fi
1262
+ nvm_err ' Checksums do not match.'
1263
+ return 1
1268
1264
}
1269
1265
1270
1266
nvm_print_versions () {
@@ -1540,8 +1536,7 @@ nvm_ensure_default_set() {
1540
1536
if [ -z " $VERSION " ]; then
1541
1537
nvm_err ' nvm_ensure_default_set: a version is required'
1542
1538
return 1
1543
- fi
1544
- if nvm_alias default > /dev/null 2>&1 ; then
1539
+ elif nvm_alias default > /dev/null 2>&1 ; then
1545
1540
# default already set
1546
1541
return 0
1547
1542
fi
@@ -1918,7 +1913,7 @@ nvm_install_source() {
1918
1913
TARBALL=" $( nvm_download_artifact " ${FLAVOR} " source " ${TYPE} " " ${VERSION} " | command tail -1) " && \
1919
1914
[ -f " ${TARBALL} " ] && \
1920
1915
TMPDIR=" $( dirname " ${TARBALL} " ) /files" && \
1921
- if (
1916
+ if ! (
1922
1917
# shellcheck disable=SC2086
1923
1918
command mkdir -p " ${TMPDIR} " && \
1924
1919
command " ${tar} " -x${tar_compression_flag} f " ${TARBALL} " -C " ${TMPDIR} " --strip-components 1 && \
@@ -1930,12 +1925,10 @@ nvm_install_source() {
1930
1925
command rm -f " ${VERSION_PATH} " 2> /dev/null && \
1931
1926
$make -j " ${NVM_MAKE_JOBS} " ${MAKE_CXX-} install
1932
1927
); then
1933
- return $?
1928
+ nvm_err " nvm: install ${VERSION} failed!"
1929
+ command rm -rf " ${TMPDIR-} "
1930
+ return 1
1934
1931
fi
1935
-
1936
- nvm_err " nvm: install ${VERSION} failed!"
1937
- command rm -rf " ${TMPDIR-} "
1938
- return 1
1939
1932
}
1940
1933
1941
1934
nvm_use_if_needed () {
@@ -2031,9 +2024,7 @@ nvm_die_on_prefix() {
2031
2024
nvm_err " nvm is not compatible with the \" NPM_CONFIG_PREFIX\" environment variable: currently set to \" $NPM_CONFIG_PREFIX \" "
2032
2025
nvm_err ' Run `unset NPM_CONFIG_PREFIX` to unset it.'
2033
2026
return 4
2034
- fi
2035
-
2036
- if ! nvm_has ' npm' ; then
2027
+ elif ! nvm_has ' npm' ; then
2037
2028
return
2038
2029
fi
2039
2030
@@ -2141,20 +2132,20 @@ nvm_check_file_permissions() {
2141
2132
setopt nonomatch
2142
2133
fi
2143
2134
for FILE in $1 /* $1 /.[! .]* $1 /..?* ; do
2144
- if [ -d " $FILE " ]; then
2145
- if ! nvm_check_file_permissions " $FILE " ; then
2146
- if [ " ${ZSH_HAS_NONOMATCH_UNSET} " -eq 1 ] && nvm_has " setopt" ; then
2147
- setopt nomatch
2148
- fi
2149
- return 2
2150
- fi
2151
- elif [ -e " $FILE " ] && [ ! -w " $FILE " ] && [ ! -O " $FILE " ]; then
2152
- nvm_err " file is not writable or self-owned: $( nvm_sanitize_path " $FILE " ) "
2135
+ if [ -d " $FILE " ]; then
2136
+ if ! nvm_check_file_permissions " $FILE " ; then
2153
2137
if [ " ${ZSH_HAS_NONOMATCH_UNSET} " -eq 1 ] && nvm_has " setopt" ; then
2154
2138
setopt nomatch
2155
2139
fi
2156
- return 1
2140
+ return 2
2141
+ fi
2142
+ elif [ -e " $FILE " ] && [ ! -w " $FILE " ] && [ ! -O " $FILE " ]; then
2143
+ nvm_err " file is not writable or self-owned: $( nvm_sanitize_path " $FILE " ) "
2144
+ if [ " ${ZSH_HAS_NONOMATCH_UNSET} " -eq 1 ] && nvm_has " setopt" ; then
2145
+ setopt nomatch
2157
2146
fi
2147
+ return 1
2148
+ fi
2158
2149
done
2159
2150
if [ " ${ZSH_HAS_NONOMATCH_UNSET} " -eq 1 ] && nvm_has " setopt" ; then
2160
2151
setopt nomatch
@@ -2378,12 +2369,10 @@ nvm() {
2378
2369
fi
2379
2370
else
2380
2371
nvm_rc_version
2381
- if [ $version_not_provided -eq 1 ]; then
2382
- if [ -z " $NVM_RC_VERSION " ]; then
2383
- unset NVM_RC_VERSION
2384
- >&2 nvm --help
2385
- return 127
2386
- fi
2372
+ if [ $version_not_provided -eq 1 ] && [ -z " $NVM_RC_VERSION " ]; then
2373
+ unset NVM_RC_VERSION
2374
+ >&2 nvm --help
2375
+ return 127
2387
2376
fi
2388
2377
provided_version=" $NVM_RC_VERSION "
2389
2378
unset NVM_RC_VERSION
@@ -3003,10 +2992,9 @@ nvm() {
3003
2992
if [ -n " $NVM_OUTPUT " ]; then
3004
2993
NVM_NO_COLORS=" ${NVM_NO_COLORS-} " nvm_print_versions " $NVM_OUTPUT "
3005
2994
return $EXIT_CODE
3006
- else
3007
- NVM_NO_COLORS=" ${NVM_NO_COLORS-} " nvm_print_versions " N/A"
3008
- return 3
3009
2995
fi
2996
+ NVM_NO_COLORS=" ${NVM_NO_COLORS-} " nvm_print_versions " N/A"
2997
+ return 3
3010
2998
;;
3011
2999
" current" )
3012
3000
nvm_version current
@@ -3040,10 +3028,9 @@ nvm() {
3040
3028
return
3041
3029
fi
3042
3030
return 1
3043
- else
3044
- nvm_err ' System version of node not found.'
3045
- return 127
3046
3031
fi
3032
+ nvm_err ' System version of node not found.'
3033
+ return 127
3047
3034
elif [ " _$VERSION " = " _∞" ]; then
3048
3035
nvm_err " The alias \" $2 \" leads to an infinite loop. Aborting."
3049
3036
return 8
0 commit comments