Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set NVM_DIR to real path to avoid symlink issues in #617 #872

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,29 @@ else
fi
unset NVM_SCRIPT_SOURCE 2>/dev/null

# Convert NVM_DIR to actual path if symlinked
export NVM_DIR=$(nvm_real_dir "${NVM_DIR}")

nvm_real_dir() {
local NVM_DIR_INPUT
NVM_DIR_INPUT="${1}"

if [ -z "${NVM_DIR_INPUT}" ]; then
nvm_err '$NVM_DIR cannot be empty'
return 2
fi

local NVM_REAL_DIR
NVM_REAL_DIR=$(command cd "${NVM_DIR_INPUT}" && command pwd -P)

if [ -z "${NVM_REAL_DIR}" ] || [ ! -d "${NVM_REAL_DIR}" ]; then
nvm_err "NVM_DIR is not a valid path"
return 2
fi

nvm_echo "${NVM_REAL_DIR}"
}

nvm_tree_contains_path() {
local tree
tree="${1-}"
Expand Down
Loading