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] [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