mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	define all functions with nvm_ prefix
This commit is contained in:
		
							
								
								
									
										22
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -5,14 +5,14 @@ | |||||||
| # Implemented by Tim Caswell <tim@creationix.com> | # Implemented by Tim Caswell <tim@creationix.com> | ||||||
| # with much bash help from Matthew Ranney | # with much bash help from Matthew Ranney | ||||||
|  |  | ||||||
| has() { | nvm_has() { | ||||||
|   type "$1" > /dev/null 2>&1 |   type "$1" > /dev/null 2>&1 | ||||||
|   return $? |   return $? | ||||||
| } | } | ||||||
|  |  | ||||||
| # Make zsh glob matching behave same as bash | # Make zsh glob matching behave same as bash | ||||||
| # This fixes the "zsh: no matches found" errors | # This fixes the "zsh: no matches found" errors | ||||||
| if has "unsetopt"; then | if nvm_has "unsetopt"; then | ||||||
|   unsetopt nomatch 2>/dev/null |   unsetopt nomatch 2>/dev/null | ||||||
|   NVM_CD_FLAGS="-q" |   NVM_CD_FLAGS="-q" | ||||||
| fi | fi | ||||||
| @@ -32,7 +32,7 @@ if [ -z "$NVM_NODEJS_ORG_MIRROR" ]; then | |||||||
| fi | fi | ||||||
|  |  | ||||||
| # Obtain nvm version from rc file | # Obtain nvm version from rc file | ||||||
| rc_nvm_version() { | nvm_rc_version() { | ||||||
|   if [ -e .nvmrc ]; then |   if [ -e .nvmrc ]; then | ||||||
|     RC_VERSION=`cat .nvmrc | head -n 1` |     RC_VERSION=`cat .nvmrc | head -n 1` | ||||||
|     echo "Found .nvmrc files with version <$RC_VERSION>" |     echo "Found .nvmrc files with version <$RC_VERSION>" | ||||||
| @@ -118,9 +118,9 @@ nvm_ls_remote() { | |||||||
| } | } | ||||||
|  |  | ||||||
| nvm_checksum() { | nvm_checksum() { | ||||||
|   if has "shasum"; then |   if nvm_has "shasum"; then | ||||||
|     checksum=$(shasum $1 | awk '{print $1}') |     checksum=$(shasum $1 | awk '{print $1}') | ||||||
|   elif has "sha1"; then |   elif nvm_has "sha1"; then | ||||||
|     checksum=$(sha1 -q $1) |     checksum=$(sha1 -q $1) | ||||||
|   else |   else | ||||||
|     checksum=$(sha1sum $1 | awk '{print $1}') |     checksum=$(sha1sum $1 | awk '{print $1}') | ||||||
| @@ -137,7 +137,7 @@ nvm_checksum() { | |||||||
|   fi |   fi | ||||||
| } | } | ||||||
|  |  | ||||||
| print_versions() { | nvm_print_versions() { | ||||||
|   local VERSION |   local VERSION | ||||||
|   local FORMAT |   local FORMAT | ||||||
|   local CURRENT=`nvm_version current` |   local CURRENT=`nvm_version current` | ||||||
| @@ -222,7 +222,7 @@ nvm() { | |||||||
|       local tarball |       local tarball | ||||||
|       local nobinary |       local nobinary | ||||||
|  |  | ||||||
|       if ! has "curl"; then |       if ! nvm_has "curl"; then | ||||||
|         echo 'NVM Needs curl to proceed.' >&2; |         echo 'NVM Needs curl to proceed.' >&2; | ||||||
|       fi |       fi | ||||||
|  |  | ||||||
| @@ -325,7 +325,7 @@ nvm() { | |||||||
|         ) |         ) | ||||||
|       then |       then | ||||||
|         nvm use $VERSION |         nvm use $VERSION | ||||||
|         if ! has "npm" ; then |         if ! nvm_has "npm" ; then | ||||||
|           echo "Installing npm..." |           echo "Installing npm..." | ||||||
|           if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then |           if [ "`expr "$VERSION" : '\(^v0\.1\.\)'`" != '' ]; then | ||||||
|             echo "npm requires node v0.2.3 or higher" |             echo "npm requires node v0.2.3 or higher" | ||||||
| @@ -400,7 +400,7 @@ nvm() { | |||||||
|         return |         return | ||||||
|       fi |       fi | ||||||
|       if [ $# -eq 1 ]; then |       if [ $# -eq 1 ]; then | ||||||
|         rc_nvm_version |         nvm_rc_version | ||||||
|         if [ -n "$RC_VERSION" ]; then |         if [ -n "$RC_VERSION" ]; then | ||||||
|             VERSION=`nvm_version $RC_VERSION` |             VERSION=`nvm_version $RC_VERSION` | ||||||
|         fi |         fi | ||||||
| @@ -465,14 +465,14 @@ nvm() { | |||||||
|       NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "${@:3}" |       NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "${@:3}" | ||||||
|     ;; |     ;; | ||||||
|     "ls" | "list" ) |     "ls" | "list" ) | ||||||
|       print_versions "`nvm_ls $2`" |       nvm_print_versions "`nvm_ls $2`" | ||||||
|       if [ $# -eq 1 ]; then |       if [ $# -eq 1 ]; then | ||||||
|         nvm alias |         nvm alias | ||||||
|       fi |       fi | ||||||
|       return |       return | ||||||
|     ;; |     ;; | ||||||
|     "ls-remote" | "list-remote" ) |     "ls-remote" | "list-remote" ) | ||||||
|         print_versions "`nvm_ls_remote $2`" |         nvm_print_versions "`nvm_ls_remote $2`" | ||||||
|         return |         return | ||||||
|     ;; |     ;; | ||||||
|     "current" ) |     "current" ) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user