[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
master
Maciej Małecki 2011-10-29 09:39:30 +02:00
parent 4692f496da
commit 09483f422e
1 changed files with 14 additions and 0 deletions

14
nvm.sh
View File

@ -200,6 +200,20 @@ nvm()
export NVM_BIN="$NVM_DIR/$VERSION/bin" export NVM_BIN="$NVM_DIR/$VERSION/bin"
echo "Now using node $VERSION" 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" ) "ls" | "list" )
if [ $# -ne 1 ]; then if [ $# -ne 1 ]; then
nvm_version $2 nvm_version $2