Compare commits

...

3 Commits

Author SHA1 Message Date
Steven Dee (Jōshin)
15a86f4b2a
Merge c1064550872bfc16afe02ec6edeb73ff3847a3da into 6b70c40f151ca051d403453bf019e1707b33bd5b 2024-10-25 23:15:32 +09:00
Jordan Harband
6b70c40f15
[Fix] nvm_install_latest_npm: avoid unbound variable
Fixes #3447
2024-10-22 22:02:01 -07:00
Jōshin
c106455087
[Fix] install.sh: install looks for .zshenv
A zsh user may have set `ZDOTDIR` to something other than `$HOME`, in which case the profile and rc files will not be located under `$HOME`. But unless the system `zshenv` has done something unusual, it is usually a safe bet that there will be a `$HOME/.zshenv` that, if nothing else, will be setting up `ZDOTDIR`.
2024-05-30 11:58:37 -07:00
2 changed files with 7 additions and 4 deletions

View File

@ -40,7 +40,7 @@ nvm_profile_is_bash_or_zsh() {
local TEST_PROFILE local TEST_PROFILE
TEST_PROFILE="${1-}" TEST_PROFILE="${1-}"
case "${TEST_PROFILE-}" in case "${TEST_PROFILE-}" in
*"/.bashrc" | *"/.bash_profile" | *"/.zshrc" | *"/.zprofile") *"/.bashrc" | *"/.bash_profile" | *"/.zshenv" | *"/.zshrc" | *"/.zprofile")
return return
;; ;;
*) *)
@ -300,11 +300,13 @@ nvm_detect_profile() {
DETECTED_PROFILE="$HOME/.zshrc" DETECTED_PROFILE="$HOME/.zshrc"
elif [ -f "$HOME/.zprofile" ]; then elif [ -f "$HOME/.zprofile" ]; then
DETECTED_PROFILE="$HOME/.zprofile" DETECTED_PROFILE="$HOME/.zprofile"
elif [ -f "$HOME/.zshenv" ]; then
DETECTED_PROFILE="$HOME/.zshenv"
fi fi
fi fi
if [ -z "$DETECTED_PROFILE" ]; then if [ -z "$DETECTED_PROFILE" ]; then
for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc" for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".zshenv"
do do
if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then if DETECTED_PROFILE="$(nvm_try_profile "${HOME}/${EACH_PROFILE}")"; then
break break

5
nvm.sh
View File

@ -196,6 +196,9 @@ nvm_install_latest_npm() {
nvm_echo 'Attempting to upgrade to the latest working version of npm...' nvm_echo 'Attempting to upgrade to the latest working version of npm...'
local NODE_VERSION local NODE_VERSION
NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")" NODE_VERSION="$(nvm_strip_iojs_prefix "$(nvm_ls_current)")"
local NPM_VERSION
NPM_VERSION="$(npm --version 2>/dev/null)"
if [ "${NODE_VERSION}" = 'system' ]; then if [ "${NODE_VERSION}" = 'system' ]; then
NODE_VERSION="$(node --version)" NODE_VERSION="$(node --version)"
elif [ "${NODE_VERSION}" = 'none' ]; then elif [ "${NODE_VERSION}" = 'none' ]; then
@ -206,8 +209,6 @@ nvm_install_latest_npm() {
nvm_err 'Unable to obtain node version.' nvm_err 'Unable to obtain node version.'
return 1 return 1
fi fi
local NPM_VERSION
NPM_VERSION="$(npm --version 2>/dev/null)"
if [ -z "${NPM_VERSION}" ]; then if [ -z "${NPM_VERSION}" ]; then
nvm_err 'Unable to obtain npm version.' nvm_err 'Unable to obtain npm version.'
return 2 return 2