diff --git a/nvm-exec b/nvm-exec index 8f18e98e49..5e88766a66 100755 --- a/nvm-exec +++ b/nvm-exec @@ -1,7 +1,8 @@ #!/usr/bin/env bash SOURCE=${BASH_SOURCE[0]} -test -L "$SOURCE" && SOURCE=$(readlink "$SOURCE") +test -L "$SOURCE" && command cd "$( dirname "$SOURCE" )" && \ + SOURCE=$(readlink "$SOURCE") DIR="$(command cd "$( dirname "$SOURCE" )" && pwd )" unset NVM_CD_FLAGS diff --git "a/test/slow/nvm exec/Running \"nvm exec --lts\" when NVM_DIR differs from nvm" "b/test/slow/nvm exec/Running \"nvm exec --lts\" when NVM_DIR differs from nvm" new file mode 100644 index 0000000000..ee314be76b --- /dev/null +++ "b/test/slow/nvm exec/Running \"nvm exec --lts\" when NVM_DIR differs from nvm" @@ -0,0 +1,18 @@ +#!/bin/sh + +set -ex + +die () { echo "$@" ; exit 1; } + +INSTPATH="$(mktemp -p "$(pwd)" -d)" +trap 'test ! -z "${INSTPATH-}" && test -d "$INSTPATH" && rm -rf "$INSTPATH"' EXIT +declare -x NVM_DIR=$INSTPATH +\. ../../../nvm.sh + +nvm install --lts || die 'nvm install --lts failed' +nvm exec --lts npm --version || die "`nvm exec` failed to run" +declare -x NODE_VERSION="$(nvm exec --lts --silent node --version)" + +ln -s ../../../../nvm-exec "$INSTPATH/nvm-exec" || die "failed to create a symlink to $INSTPATH/" +"$INSTPATH/nvm-exec" npm ls > /dev/null || die "`nvm exec` failed to run using nvm-exec helper" +