Skip to content
Myr

Merge pull request #491 from creationix/nvm_exec

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Add `nvm exec` command.

authored by Jordan Harband · committed by Jordan Harband · parents 6dc602b, a703d35 · Browse files · 6 files+80 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

6 files+80 added−1 removed

  • tests:+52 added−0 removed
  • other:+28 added−1 removed

6 files+80 added−1 removed

added:test/slow/nvm exec/Running "nvm exec 0.x" should work+13 added
1#!/bin/sh23die () { echo $@ ; exit 1; }45. ../../../nvm.sh67nvm use 0.108NPM_VERSION_TEN="$(npm --version)"910nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"1112[ "$(nvm exec 0.10 npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "`nvm exec` failed to run with the correct version"13
added:test/slow/nvm exec/Running "nvm exec" should pick up .nvmrc version+17 added
1#!/bin/sh23die () { echo $@ ; exit 1; }45. ../../../nvm.sh67nvm use 0.10.78NPM_VERSION_TEN="$(npm --version)"910nvm use 0.11.7 && [ "$(node --version)" = "v0.11.7" ] || die "\`nvm use\` failed!"1112echo "0.10.7" > .nvmrc1314[ "$(nvm exec npm --version | tail -1)" = "$NPM_VERSION_TEN" ] || die "\`nvm exec\` failed to run with the .nvmrc version"1516[ "$(nvm exec npm --version | head -1)" = "Found '$PWD/.nvmrc' with version <0.10.7>" ] || die "\`nvm exec\` failed to print out the \"found in .nvmrc\" message"17
added:test/slow/nvm exec/setup_dir+10 added
1#!/bin/sh23. ../../../nvm.sh4nvm install 0.10.75nvm install 0.11.767if [ -f ".nvmrc" ]; then8 mv .nvmrc .nvmrc.bak9fi10
added:test/slow/nvm exec/teardown_dir+12 added
1#!/bin/sh23. ../../../nvm.sh4nvm uninstall v0.10.75nvm uninstall v0.11.767rm .nvmrc89if [ -f ".nvmrc.bak" ]; then10 mv .nvmrc.bak .nvmrc11fi12
modified:nvm.sh+23 added
637 unmodified lines
638 RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`639 echo "Running node $VERSION"640 NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"641 ;;642 "exec" )643 shift644645 local provided_version646 provided_version=$1647 if [ -n "$provided_version" ]; then648 VERSION=`nvm_version $provided_version`649 if [ $VERSION = "N/A" ]; then650 provided_version=''651 nvm_rc_version652 VERSION=`nvm_version $NVM_RC_VERSION`653 else654 shift655 fi656 fi657658 if [ ! -d "$NVM_DIR/$VERSION" ]; then659 echo "$VERSION version is not installed yet" >&2660 return 1661 fi662 echo "Running node $VERSION"663 NODE_VERSION=$VERSION $NVM_DIR/nvm-exec "$@"664 ;;665 "ls" | "list" )666 local NVM_LS_OUTPUT667 local NVM_LS_EXIT_CODE668 NVM_LS_OUTPUT=$(nvm_ls "$2")
94 unmodified lines
modified:README.markdown+5 added-1 removed