From 09483f422e074379908b175af84a50ba4ac00844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 29 Oct 2011 09:39:30 +0200 Subject: [PATCH 1/3] [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 --- nvm.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/nvm.sh b/nvm.sh index e9aa070..5fae69f 100755 --- a/nvm.sh +++ b/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 From 335a25332388edef7f7ff5f63a27c0c467a610c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 29 Oct 2011 10:04:37 +0200 Subject: [PATCH 2/3] [docs] Document `run` command --- README.markdown | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.markdown b/README.markdown index 09c4d1d..fe5be56 100644 --- a/README.markdown +++ b/README.markdown @@ -27,6 +27,10 @@ And then in any new shell just use the installed version: nvm use v0.4.1 +Or you can just run it: + + nvm run v0.4.1 + If you want to see what versions are available: nvm ls From 53e1764a8a397539ce2a0c13b2b2532c86e9cbee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 5 Nov 2011 17:32:17 +0100 Subject: [PATCH 3/3] [feature] Allow passing additional arguments to node For example: nvm run v0.6.0 myApp.js --- nvm.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nvm.sh b/nvm.sh index 5fae69f..c4e6596 100755 --- a/nvm.sh +++ b/nvm.sh @@ -202,7 +202,7 @@ nvm() ;; "run" ) # run given version of node - if [ $# -ne 2 ]; then + if [ $# -lt 2 ]; then nvm help return fi @@ -212,7 +212,7 @@ nvm() return; fi echo "Running node $VERSION" - $NVM_DIR/$VERSION/bin/node + $NVM_DIR/$VERSION/bin/node "${@:3}" ;; "ls" | "list" ) if [ $# -ne 1 ]; then