mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 14:51:49 +00:00
Check for both files then up to the parent
This commit is contained in:
parent
e642610335
commit
1810d36fa5
33
nvm.sh
33
nvm.sh
@ -274,24 +274,26 @@ nvm_tree_contains_path() {
|
|||||||
# Traverse up in directory tree to find containing folder
|
# Traverse up in directory tree to find containing folder
|
||||||
nvm_find_up() {
|
nvm_find_up() {
|
||||||
local path
|
local path
|
||||||
|
local file
|
||||||
path="${PWD}"
|
path="${PWD}"
|
||||||
while [ "${path}" != "" ] && [ ! -f "${path}/${1-}" ]; do
|
|
||||||
path=${path%/*}
|
# Iterate through the multiple files
|
||||||
|
while [ $# -ne 0 ]; do
|
||||||
|
# Look for files in turn in this path
|
||||||
|
while [ "${path}" != "" ]; do
|
||||||
|
# Is the file here?
|
||||||
|
if [ ! -f "${path}/${1}" ]; then
|
||||||
|
file="${path}/${1}"
|
||||||
|
nvm_echo $file
|
||||||
|
break 2
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
shift
|
||||||
done
|
done
|
||||||
nvm_echo "${path}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_find_nvmrc() {
|
nvm_find_nvmrc() {
|
||||||
local dir
|
nvm_echo "$(nvm_find_up '.nvmrc' '.node-version')"
|
||||||
dir="$(nvm_find_up '.nvmrc')"
|
|
||||||
if [ -e "${dir}/.nvmrc" ]; then
|
|
||||||
nvm_echo "${dir}/.nvmrc"
|
|
||||||
else
|
|
||||||
dir="$(nvm_find_up '.node-version')"
|
|
||||||
if [ -e "${dir}/.node-version" ]; then
|
|
||||||
nvm_echo "${dir}/.node-version"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_rc_version() {
|
nvm_rc_version() {
|
||||||
@ -302,12 +304,13 @@ nvm_rc_version() {
|
|||||||
nvm_err "No .nvmrc or .node-version file found"
|
nvm_err "No .nvmrc or .node-version file found"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
NVMRC_BASENAME="$(command basename "$NVMRC_PATH")"
|
||||||
read -r NVM_RC_VERSION < "${NVMRC_PATH}" || printf ''
|
read -r NVM_RC_VERSION < "${NVMRC_PATH}" || printf ''
|
||||||
if [ ! -n "${NVM_RC_VERSION}" ]; then
|
if [ ! -n "${NVM_RC_VERSION}" ]; then
|
||||||
nvm_err "Warning: empty nvm file found at \"${NVMRC_PATH}\""
|
nvm_err "Warning: empty \"${NVMRC_BASENAME}\" file found at \"${NVMRC_PATH}\""
|
||||||
return 2
|
return 2
|
||||||
fi
|
fi
|
||||||
nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
|
nvm_echo "Found \"${NVMRC_BASENAME}\" with version <${NVM_RC_VERSION}>"
|
||||||
}
|
}
|
||||||
|
|
||||||
nvm_clang_version() {
|
nvm_clang_version() {
|
||||||
|
Loading…
Reference in New Issue
Block a user