Node 27 and later publish Alpha prereleases, like `v27.0.0-alpha.1.0.0`, in the main `index.tab`, so `nvm install node` or `nvm install 27` would otherwise pick one. Every version is in exactly one category: `alpha` and `lts` or `non-lts` (by index.tab's LTS column) on the node mirror, and `iojs` on the io.js mirror. Commands select from every category but `alpha`, unless `$NVM_ONLY` lists others, and every command that selects or lists versions takes `--only=<categories>` to override both; an exact alpha needs `alpha` selected, like any other. An LTS selection, like `--lts` or an `lts/` version, can't combine with an `--only=` that excludes `lts`. Telling installed `lts` and `non-lts` versions apart uses the recorded LTS status, and fails rather than guess without it. `nvm alias` also stores `--only=`, so `nvm alias default --only=alpha node` makes the latest installed alpha the default, including in a new shell.
25 lines
638 B
Bash
Executable File
25 lines
638 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
|
unset NVM_CD_FLAGS
|
|
|
|
# shellcheck disable=SC1090,SC1091
|
|
\. "$DIR/nvm.sh" --no-use
|
|
|
|
if [ -n "$NODE_VERSION" ]; then
|
|
nvm use -- "$NODE_VERSION" > /dev/null || exit 127
|
|
else
|
|
{ NVM_RC_VERSION="$(nvm_rc_version 3>&1 1>&4)"; } 4>&1 && nvm_ensure_version_installed "$NVM_RC_VERSION";
|
|
if ! nvm use >/dev/null 2>&1; then
|
|
nvm_err 'nvm-exec: unable to select a node version'
|
|
# shellcheck disable=SC2016
|
|
nvm_err ' Set `NODE_VERSION` (e.g. `NODE_VERSION=default`), or add an `.nvmrc` file.'
|
|
exit 127
|
|
fi
|
|
fi
|
|
|
|
unset NVM_ONLY_SELECTED
|
|
|
|
exec "$@"
|