Compare commits

...

3 Commits

18
nvm.sh
View File

@ -83,7 +83,7 @@ nvm_has_colors() {
if nvm_has tput; then if nvm_has tput; then
NVM_NUM_COLORS="$(tput -T "${TERM:-vt100}" colors)" NVM_NUM_COLORS="$(tput -T "${TERM:-vt100}" colors)"
fi fi
[ "${NVM_NUM_COLORS:--1}" -ge 8 ] [ "${NVM_NUM_COLORS:--1}" -ge 8 ] && [ "${NVM_NO_COLORS-}" != '--no-colors' ]
} }
nvm_curl_libz_support() { nvm_curl_libz_support() {
@ -434,6 +434,7 @@ else
fi fi
unset NVM_SCRIPT_SOURCE 2>/dev/null unset NVM_SCRIPT_SOURCE 2>/dev/null
nvm_tree_contains_path() { nvm_tree_contains_path() {
local tree local tree
tree="${1-}" tree="${1-}"
@ -449,14 +450,21 @@ nvm_tree_contains_path() {
previous_pathdir="${node_path}" previous_pathdir="${node_path}"
local pathdir local pathdir
pathdir=$(dirname "${previous_pathdir}") pathdir=$(dirname "${previous_pathdir}")
# Convert tree path to canonical form for case-insensitive comparison
local tree_canonical
tree_canonical=$(cd "${tree}" && pwd -P)
while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] && while [ "${pathdir}" != '' ] && [ "${pathdir}" != '.' ] && [ "${pathdir}" != '/' ] &&
[ "${pathdir}" != "${tree}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do [ "${pathdir}" != "${tree_canonical}" ] && [ "${pathdir}" != "${previous_pathdir}" ]; do
previous_pathdir="${pathdir}" previous_pathdir="${pathdir}"
pathdir=$(dirname "${previous_pathdir}") pathdir=$(dirname "${previous_pathdir}")
done done
[ "${pathdir}" = "${tree}" ]
[ "${pathdir}" = "${tree_canonical}" ]
} }
nvm_find_project_dir() { nvm_find_project_dir() {
local path_ local path_
path_="${PWD}" path_="${PWD}"
@ -1094,7 +1102,7 @@ nvm_print_formatted_alias() {
fi fi
local ARROW local ARROW
ARROW='->' ARROW='->'
if [ -z "${NVM_NO_COLORS}" ] && nvm_has_colors; then if nvm_has_colors; then
ARROW='\033[0;90m->\033[0m' ARROW='\033[0;90m->\033[0m'
if [ "_${DEFAULT}" = '_true' ]; then if [ "_${DEFAULT}" = '_true' ]; then
NEWLINE=" \033[${DEFAULT_COLOR}(default)\033[0m\n" NEWLINE=" \033[${DEFAULT_COLOR}(default)\033[0m\n"
@ -1832,7 +1840,7 @@ nvm_print_versions() {
DEFAULT_COLOR=$(nvm_get_colors 5) DEFAULT_COLOR=$(nvm_get_colors 5)
LTS_COLOR=$(nvm_get_colors 6) LTS_COLOR=$(nvm_get_colors 6)
if [ -z "${NVM_NO_COLORS-}" ] && nvm_has_colors; then if nvm_has_colors; then
NVM_HAS_COLORS=1 NVM_HAS_COLORS=1
fi fi