Skip to content

Commit

Permalink
[New] Allow all commands that require .nvmrc to use the --config
Browse files Browse the repository at this point in the history
…flag
  • Loading branch information
victormihalache committed Nov 21, 2023
1 parent fb11d3c commit 73929d9
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3612,6 +3612,7 @@ nvm() {
local NVM_LTS
local IS_VERSION_FROM_NVMRC
IS_VERSION_FROM_NVMRC=0
local NVM_RC_PATH

while [ $# -ne 0 ]; do
case "$1" in
Expand All @@ -3623,6 +3624,10 @@ nvm() {
--) ;;
--lts) NVM_LTS='*' ;;
--lts=*) NVM_LTS="${1##--lts=}" ;;
--config=*)
NVM_RC_PATH="${1#--config=}"
shift
;;
--*) ;;
*)
if [ -n "${1-}" ]; then
Expand All @@ -3636,7 +3641,7 @@ nvm() {
if [ -n "${NVM_LTS-}" ]; then
VERSION="$(nvm_match_version "lts/${NVM_LTS:-*}")"
elif [ -z "${PROVIDED_VERSION-}" ]; then
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version "$NVM_RC_PATH"
if [ -n "${NVM_RC_VERSION-}" ]; then
PROVIDED_VERSION="${NVM_RC_VERSION}"
IS_VERSION_FROM_NVMRC=1
Expand Down Expand Up @@ -3746,6 +3751,7 @@ nvm() {
local NVM_SILENT
local NVM_SILENT_ARG
local NVM_LTS
local NVM_RC_PATH
while [ $# -gt 0 ]; do
case "$1" in
--silent)
Expand All @@ -3755,6 +3761,10 @@ nvm() {
;;
--lts) NVM_LTS='*' ; shift ;;
--lts=*) NVM_LTS="${1##--lts=}" ; shift ;;
--config=*)
NVM_RC_PATH="${1#--config=}"
shift
;;
*)
if [ -n "$1" ]; then
break
Expand All @@ -3766,7 +3776,7 @@ nvm() {
done

if [ $# -lt 1 ] && [ -z "${NVM_LTS-}" ]; then
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version && has_checked_nvmrc=1
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version "$NVM_RC_PATH" && has_checked_nvmrc=1
if [ -n "${NVM_RC_VERSION-}" ]; then
VERSION="$(nvm_version "${NVM_RC_VERSION-}")" ||:
fi
Expand All @@ -3784,7 +3794,7 @@ nvm() {
if [ "_${VERSION:-N/A}" = '_N/A' ] && ! nvm_is_valid_version "${provided_version}"; then
provided_version=''
if [ $has_checked_nvmrc -ne 1 ]; then
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version && has_checked_nvmrc=1
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version $NVM_RC_PATH && has_checked_nvmrc=1
fi
provided_version="${NVM_RC_VERSION}"
IS_VERSION_FROM_NVMRC=1
Expand Down Expand Up @@ -3822,11 +3832,16 @@ nvm() {
"exec")
local NVM_SILENT
local NVM_LTS
local NVM_RC_PATH
while [ $# -gt 0 ]; do
case "$1" in
--silent) NVM_SILENT=1 ; shift ;;
--lts) NVM_LTS='*' ; shift ;;
--lts=*) NVM_LTS="${1##--lts=}" ; shift ;;
--config=*)
NVM_RC_PATH="${1#--config=}"
shift
;;
--) break ;;
--*)
nvm_err "Unsupported option \"$1\"."
Expand All @@ -3850,7 +3865,7 @@ nvm() {
elif [ -n "${provided_version}" ]; then
VERSION="$(nvm_version "${provided_version}")" ||:
if [ "_${VERSION}" = '_N/A' ] && ! nvm_is_valid_version "${provided_version}"; then
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version && has_checked_nvmrc=1
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version "$NVM_RC_PATH" && has_checked_nvmrc=1
provided_version="${NVM_RC_VERSION}"
unset NVM_RC_VERSION
VERSION="$(nvm_version "${provided_version}")" ||:
Expand Down Expand Up @@ -3974,16 +3989,21 @@ nvm() {
"which")
local NVM_SILENT
local provided_version
local NVM_RC_PATH
while [ $# -ne 0 ]; do
case "${1}" in
--silent) NVM_SILENT=1 ;;
--config=*)
NVM_RC_PATH="${1#--config=}"
shift
;;
--) ;;
*) provided_version="${1-}" ;;
esac
shift
done
if [ -z "${provided_version-}" ]; then
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version
NVM_SILENT="${NVM_SILENT:-0}" nvm_rc_version "$NVM_RC_PATH"
if [ -n "${NVM_RC_VERSION}" ]; then
provided_version="${NVM_RC_VERSION}"
VERSION=$(nvm_version "${NVM_RC_VERSION}") ||:
Expand Down

0 comments on commit 73929d9

Please sign in to comment.