mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-12 15:11:50 +00:00
24 lines
471 B
Bash
Executable File
24 lines
471 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
function find_nvm_dir() {
|
|
if which realpath >& /dev/null; then
|
|
dirname "$(realpath "$0")"
|
|
else
|
|
command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd
|
|
fi
|
|
}
|
|
|
|
DIR="$(find_nvm_dir)"
|
|
|
|
# shellcheck disable=SC1090
|
|
\. "$DIR/nvm.sh" --no-use
|
|
|
|
if [ -n "$NODE_VERSION" ]; then
|
|
nvm use "$NODE_VERSION" > /dev/null || exit 127
|
|
elif ! nvm use >/dev/null 2>&1; then
|
|
echo "No NODE_VERSION provided; no .nvmrc file found" >&2
|
|
exit 127
|
|
fi
|
|
|
|
exec "$@"
|