mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-11-04 06:57:12 +00:00 
			
		
		
		
	Check for both files then up to the parent
This commit is contained in:
		
							parent
							
								
									008bf47d3f
								
							
						
					
					
						commit
						dba3404693
					
				
							
								
								
									
										34
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								nvm.sh
									
									
									
									
									
								
							@ -452,24 +452,27 @@ nvm_find_project_dir() {
 | 
				
			|||||||
# 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_}" != "" ] && [ "${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_}" != "" ] && [ "${path_}" != '.' ]; do
 | 
				
			||||||
 | 
					      # Is the file here?
 | 
				
			||||||
 | 
					      if [ -f "${path_}/${1-}" ]; then
 | 
				
			||||||
 | 
					        file="${path_}/${1-}"
 | 
				
			||||||
 | 
					        echo "${file}"
 | 
				
			||||||
 | 
					        break 2
 | 
				
			||||||
 | 
					      fi
 | 
				
			||||||
 | 
					      path_=${path_%/*}
 | 
				
			||||||
 | 
					    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
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Obtain nvm version from rc file
 | 
					# Obtain nvm version from rc file
 | 
				
			||||||
@ -483,15 +486,16 @@ nvm_rc_version() {
 | 
				
			|||||||
    fi
 | 
					    fi
 | 
				
			||||||
    return 1
 | 
					    return 1
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
 | 
					  NVMRC_BASENAME="$(command basename "$NVMRC_PATH")"
 | 
				
			||||||
  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
 | 
					  NVM_RC_VERSION="$(command head -n 1 "${NVMRC_PATH}" | command tr -d '\r')" || command printf ''
 | 
				
			||||||
  if [ -z "${NVM_RC_VERSION}" ]; then
 | 
					  if [ -z "${NVM_RC_VERSION}" ]; then
 | 
				
			||||||
    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
 | 
					    if [ "${NVM_SILENT:-0}" -ne 1 ]; then
 | 
				
			||||||
      nvm_err "Warning: empty nvm file found at \"${NVMRC_PATH}\""
 | 
					      nvm_err "Warning: empty '${NVMRC_BASENAME}' file found at \"${NVMRC_PATH}\""
 | 
				
			||||||
    fi
 | 
					    fi
 | 
				
			||||||
    return 2
 | 
					    return 2
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
  if [ "${NVM_SILENT:-0}" -ne 1 ]; then
 | 
					  if [ "${NVM_SILENT:-0}" -ne 1 ]; then
 | 
				
			||||||
    nvm_echo "Found '${NVMRC_PATH}' with version <${NVM_RC_VERSION}>"
 | 
					    nvm_echo "Found '${NVMRC_BASENAME}' with version <${NVM_RC_VERSION}>"
 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user