[New] select versions by category: alpha, lts, non-lts, iojs; exclude alphas by default
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.
This commit is contained in:
13 files changed
+1213
-51
No files matched your search
Executable
+43
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
|
||||
ORIG_NVM_DIR="${NVM_DIR}"
|
||||
TMP_DIR=''
|
||||
|
||||
cleanup () {
|
||||
case "${TMP_DIR}" in
|
||||
/*) rm -rf "${TMP_DIR}" ;;
|
||||
esac
|
||||
NVM_DIR="${ORIG_NVM_DIR}"
|
||||
export NVM_DIR
|
||||
unset NVM_ONLY
|
||||
}
|
||||
|
||||
die () { echo "$@" ; cleanup ; exit 1; }
|
||||
|
||||
: nvm.sh
|
||||
\. ../../../nvm.sh
|
||||
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
NVM_DIR="${TMP_DIR}/nvm"
|
||||
export NVM_DIR
|
||||
unset NVM_ONLY
|
||||
|
||||
CACHE_DIR="$(nvm_cache_dir)"
|
||||
SUFFIX="$(nvm_get_os)-$(nvm_get_arch)"
|
||||
mkdir -p "${CACHE_DIR}/bin/node-v27.0.0-alpha.1.2.0-${SUFFIX}" "${CACHE_DIR}/src/node-v27.0.0-alpha.1.10.0" "${CACHE_DIR}/bin/node-v26.12.1-${SUFFIX}" \
|
||||
|| die 'could not create cached artifacts'
|
||||
|
||||
OUTPUT="$(nvm_ls_cached | tr '\n' ' ')"
|
||||
[ "_${OUTPUT}" = '_v26.12.1 ' ] || die "cached alphas should be excluded by default; got >${OUTPUT}<"
|
||||
|
||||
NVM_ONLY=alpha
|
||||
OUTPUT="$(nvm_ls_cached | tr '\n' ' ')"
|
||||
[ "_${OUTPUT}" = '_v27.0.0-alpha.1.2.0 v27.0.0-alpha.1.10.0 ' ] || die "NVM_ONLY=alpha should list cached alphas, in order; got >${OUTPUT}<"
|
||||
OUTPUT="$(nvm_ls_cached 27.0.0-alpha.1.2 | tr '\n' ' ')"
|
||||
[ "_${OUTPUT}" = '_v27.0.0-alpha.1.2.0 ' ] || die "a partial alpha should match only at a dot; got >${OUTPUT}<"
|
||||
|
||||
NVM_ONLY='alpha,lts,non-lts,iojs'
|
||||
OUTPUT="$(nvm_ls_cached v27.0.0)"
|
||||
[ -z "${OUTPUT}" ] || die "v27.0.0 is not one of its alphas; got >${OUTPUT}<"
|
||||
|
||||
cleanup
|
||||
Reference in new issue
Block a user