Skip to content
Myr

utility method for append path, fixes #414

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

authored by Koen Punt · committed by Koen Punt · parent 0ecb287 · Browse files · 2 files+30 added−4 removed
This commit

State

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

Diff stats

2 files+30 added−4 removed

  • tests:+18 added−0 removed
  • other:+12 added−4 removed

2 files+30 added−4 removed

added:test/fast/Unit tests/nvm_prepend_path+18 added
1#!/bin/sh23die () { echo $@ ; exit 1; }45. ../../../nvm.sh67TEST_PATH=/usr/bin:/usr/local/bin89NEW_PATH=`nvm_prepend_path "$TEST_PATH" "$NVM_DIR/v0.2.5/bin"`1011[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin:/usr/bin:/usr/local/bin" ] || die "Not correctly prepended: $STRIPPED_PATH "121314EMPTY_PATH=1516NEW_PATH=`nvm_prepend_path "$EMPTY_PATH" "$NVM_DIR/v0.2.5/bin"`1718[ "$NEW_PATH" = "$NVM_DIR/v0.2.5/bin" ] || die "Not correctly prepended: $STRIPPED_PATH "
modified:nvm.sh+12 added-4 removed
99 unmodified lines
100nvm_strip_path() {101 echo "$1" | sed -e "s#$NVM_DIR/[^/]*$2[^:]*:##g" -e "s#:$NVM_DIR/[^/]*$2[^:]*##g" -e "s#$NVM_DIR/[^/]*$2[^:]*##g"102}103104nvm_prepend_path() {105 if [ -z "$1" ]; then106 echo "$2"107 else108 echo "$2:$1"109 fi110}111112nvm_binary_available() {113 # binaries started with node 0.8.6114 local MINIMAL="0.8.6"115 local VERSION=$1
369 unmodified lines
485 fi486 # Strip other version from PATH487 PATH=`nvm_strip_path "$PATH" "/bin"`488 # Prepend current version481 PATH="$NVM_DIR/$VERSION/bin:$PATH"489 PATH=`nvm_prepend_path "$PATH" "$NVM_DIR/$VERSION/bin"`490 if [ -z "$MANPATH" ]; then491 MANPATH=$(manpath)492 fi493 # Strip other version from MANPATH494 MANPATH=`nvm_strip_path "$MANPATH" "/share/man"`495 # Prepend current version488 MANPATH="$NVM_DIR/$VERSION/share/man:$MANPATH"496 MANPATH=`nvm_prepend_path "$MANPATH" "$NVM_DIR/$VERSION/share/man"`497 # Strip other version from NODE_PATH498 NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`499 # Prepend current version492 NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"500 NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`501 export PATH502 hash -r503 export MANPATH504 export NODE_PATH
37 unmodified lines
542 echo "$VERSION version is not installed yet"543 return;544 fi545 RUN_NODE_PATH=`nvm_strip_path "$NODE_PATH" "/lib/node_modules"`538 RUN_NODE_PATH="$NVM_DIR/$VERSION/lib/node_modules:$NODE_PATH"546 RUN_NODE_PATH=`nvm_prepend_path "$NODE_PATH" "$NVM_DIR/$VERSION/lib/node_modules"`547 echo "Running node $VERSION"548 NODE_PATH=$RUN_NODE_PATH $NVM_DIR/$VERSION/bin/node "$@"549 ;;550 "ls" | "list" )
87 unmodified lines