[Fix] `nvm alias`/`nvm_list_aliases`: support `lts/` aliases
See #2692
parent
2459d17741
commit
430860a8be
5
nvm.sh
5
nvm.sh
|
@ -988,6 +988,11 @@ nvm_list_aliases() {
|
|||
NVM_ALIAS_DIR="$(nvm_alias_path)"
|
||||
command mkdir -p "${NVM_ALIAS_DIR}/lts"
|
||||
|
||||
if [ "${ALIAS}" != "${ALIAS#lts/}" ]; then
|
||||
nvm_alias "${ALIAS}"
|
||||
return $?
|
||||
fi
|
||||
|
||||
nvm_is_zsh && unsetopt local_options nomatch
|
||||
(
|
||||
local ALIAS_PATH
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
|
||||
\. ../../../nvm.sh
|
||||
|
||||
die () {
|
||||
echo "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
nvm_alias_path() {
|
||||
nvm_echo "../../../alias"
|
||||
}
|
||||
|
||||
MOCKS_DIR="../Unit tests/mocks"
|
||||
|
||||
EXPECTED_OUTPUT="$(cat "$MOCKS_DIR/lts-star.txt")"
|
||||
STDOUT_OUTPUT="$(nvm_list_aliases "lts/*")"
|
||||
STDERR_OUTPUT="$(nvm_list_aliases "lts/*" 2>&1 >/dev/null)"
|
||||
|
||||
[ -z "${STDERR_OUTPUT}" ] || die "expected no stderr output, got >${STDERR_OUTPUT}<"
|
||||
[ "${STDOUT_OUTPUT}" = "${EXPECTED_OUTPUT}" ] || die "expected ${EXPECTED_OUTPUT}, got >${STDOUT_OUTPUT}<"
|
|
@ -0,0 +1 @@
|
|||
lts/gallium
|
|
@ -32,6 +32,7 @@ nvm ls-remote node > "$MOCKS_DIR/nvm ls-remote node.txt"
|
|||
nvm ls-remote iojs > "$MOCKS_DIR/nvm ls-remote iojs.txt"
|
||||
nvm_print_implicit_alias remote stable > "$MOCKS_DIR/nvm_print_implicit_alias remote stable.txt"
|
||||
nvm_ls_remote stable > "$MOCKS_DIR/nvm_ls_remote stable.txt"
|
||||
nvm alias "lts/*" > "$MOCKS_DIR/lts-star.txt"
|
||||
|
||||
set +e
|
||||
NVM_NODEJS_ORG_MIRROR=https://nodejs.org/download/nightly/ nvm_ls_remote > "$MOCKS_DIR/nvm_ls_remote nightly.txt"
|
||||
|
|
Loading…
Reference in New Issue