mirror of
				https://github.com/nvm-sh/nvm.git
				synced 2025-10-31 10:15:53 +08:00 
			
		
		
		
	[feature] Add run command
				
					
				
			`run` command runs given node version without modyfing global state:
    [maciej@PC07 nvm (run)]$ node --version
    v0.4.12
    [maciej@PC07 nvm (run)]$ nvm run 0.4.12
    Running node v0.4.12
    > process.version
    'v0.4.12'
    > [maciej@PC07 nvm (run)]$ nvm run 0.5.9
    Running node v0.5.9
    > process.version
    'v0.5.9'
    > [maciej@PC07 nvm (run)]$ node --version
    v0.4.12
			
			
This commit is contained in:
		
							
								
								
									
										14
									
								
								nvm.sh
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								nvm.sh
									
									
									
									
									
								
							| @@ -200,6 +200,20 @@ nvm() | ||||
|       export NVM_BIN="$NVM_DIR/$VERSION/bin" | ||||
|       echo "Now using node $VERSION" | ||||
|     ;; | ||||
|     "run" ) | ||||
|       # run given version of node | ||||
|       if [ $# -ne 2 ]; then | ||||
|         nvm help | ||||
|         return | ||||
|       fi | ||||
|       VERSION=`nvm_version $2` | ||||
|       if [ ! -d $NVM_DIR/$VERSION ]; then | ||||
|         echo "$VERSION version is not installed yet" | ||||
|         return; | ||||
|       fi | ||||
|       echo "Running node $VERSION" | ||||
|       $NVM_DIR/$VERSION/bin/node | ||||
|     ;; | ||||
|     "ls" | "list" ) | ||||
|       if [ $# -ne 1 ]; then | ||||
|         nvm_version $2 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user