mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	nvm run: add --lts/--lts=argon support
				
					
				
			This commit is contained in:
		
							
								
								
									
										24
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -1847,6 +1847,8 @@ nvm() { | ||||
|       nvm_echo '    --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.' | ||||
|       nvm_echo '    --lts=<LTS name>                        Uses automatic alias for provided LTS line, if available.' | ||||
|       nvm_echo '  nvm run [--silent] <version> [<args>]     Run `node` on <version> with <args> as arguments. Uses .nvmrc if available' | ||||
|       nvm_echo '    --lts                                   Uses automatic LTS (long-term support) alias `lts/*`, if available.' | ||||
|       nvm_echo '    --lts=<LTS name>                        Uses automatic alias for provided LTS line, if available.' | ||||
|       nvm_echo '  nvm current                               Display currently activated version' | ||||
|       nvm_echo '  nvm ls                                    List installed versions' | ||||
|       nvm_echo '  nvm ls <version>                          List versions matching a given <version>' | ||||
| @@ -2332,10 +2334,13 @@ nvm() { | ||||
|       shift | ||||
|  | ||||
|       local NVM_SILENT | ||||
|       local NVM_LTS | ||||
|       while [ $# -gt 0 ] | ||||
|       do | ||||
|         case "$1" in | ||||
|           --silent) NVM_SILENT='--silent' ; shift ;; | ||||
|           --lts) NVM_LTS='*' ; shift ;; | ||||
|           --lts=*) NVM_LTS="${1##--lts=}" ; shift ;; | ||||
|           *) | ||||
|             if [ -n "$1" ]; then | ||||
|               break | ||||
| @@ -2346,7 +2351,7 @@ nvm() { | ||||
|         esac | ||||
|       done | ||||
|  | ||||
|       if [ $# -lt 1 ]; then | ||||
|       if [ $# -lt 1 ] && [ -z "${NVM_LTS-}" ]; then | ||||
|         if [ -n "${NVM_SILENT-}" ]; then | ||||
|           nvm_rc_version >/dev/null 2>&1 && has_checked_nvmrc=1 | ||||
|         else | ||||
| @@ -2354,19 +2359,18 @@ nvm() { | ||||
|         fi | ||||
|         if [ -n "$NVM_RC_VERSION" ]; then | ||||
|           VERSION="$(nvm_version "$NVM_RC_VERSION" || return 0)" | ||||
|         else | ||||
|           VERSION='N/A' | ||||
|         fi | ||||
|         if [ $VERSION = "N/A" ]; then | ||||
|         if [ "${VERSION:-N/A}" = 'N/A' ]; then | ||||
|           >&2 nvm --help | ||||
|           return 127 | ||||
|         fi | ||||
|       fi | ||||
|  | ||||
|       if [ -z "${NVM_LTS-}" ]; then | ||||
|         provided_version="$1" | ||||
|         if [ -n "$provided_version" ]; then | ||||
|           VERSION="$(nvm_version "$provided_version" || return 0)" | ||||
|         if [ "_$VERSION" = "_N/A" ] && ! nvm_is_valid_version "$provided_version"; then | ||||
|           if [ "_${VERSION:-N/A}" = '_N/A' ] && ! nvm_is_valid_version "$provided_version"; then | ||||
|             provided_version='' | ||||
|             if [ $has_checked_nvmrc -ne 1 ]; then | ||||
|             if [ -n "${NVM_SILENT-}" ]; then | ||||
| @@ -2380,6 +2384,7 @@ nvm() { | ||||
|             shift | ||||
|           fi | ||||
|         fi | ||||
|       fi | ||||
|  | ||||
|       local NVM_IOJS | ||||
|       if nvm_is_iojs_version "$VERSION"; then | ||||
| @@ -2394,12 +2399,17 @@ nvm() { | ||||
|         ZSH_HAS_SHWORDSPLIT_UNSET="$(setopt | nvm_grep shwordsplit > /dev/null && nvm_echo $? || nvm_echo $?)" | ||||
|         setopt shwordsplit | ||||
|       fi | ||||
|       local LTS_ARG | ||||
|       if [ -n "${NVM_LTS-}" ]; then | ||||
|         LTS_ARG="--lts=${NVM_LTS-}" | ||||
|         VERSION='' | ||||
|       fi | ||||
|       if [ "_$VERSION" = "_N/A" ]; then | ||||
|         nvm_ensure_version_installed "$provided_version" | ||||
|       elif [ "$NVM_IOJS" = true ]; then | ||||
|         nvm exec "${NVM_SILENT-}" "$VERSION" iojs "$@" | ||||
|         nvm exec "${NVM_SILENT-}" "${LTS_ARG-}" "$VERSION" iojs "$@" | ||||
|       else | ||||
|         nvm exec "${NVM_SILENT-}" "$VERSION" node "$@" | ||||
|         nvm exec "${NVM_SILENT-}" "${LTS_ARG-}" "$VERSION" node "$@" | ||||
|       fi | ||||
|       EXIT_CODE="$?" | ||||
|       if [ "$ZSH_HAS_SHWORDSPLIT_UNSET" -eq 1 ] && nvm_has "unsetopt"; then | ||||
|   | ||||
		Reference in New Issue
	
	Block a user