Make `nvm alias` list implicit "stable" and "unstable" aliases when they're not already aliases.
parent
f9565ff675
commit
5dc7af6285
10
nvm.sh
10
nvm.sh
|
@ -876,6 +876,16 @@ nvm() {
|
|||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
for ALIAS in "stable" "unstable"; do
|
||||
if [ ! -f "$NVM_DIR/alias/$ALIAS" ]; then
|
||||
if [ $# -lt 2 ] || [ "~$ALIAS" = "~$2" ]; then
|
||||
DEST="$(nvm_print_implicit_alias local "$ALIAS")"
|
||||
VERSION="$(nvm_version "$DEST")"
|
||||
echo "$ALIAS -> $DEST (-> $VERSION) (default)"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
return
|
||||
fi
|
||||
if [ -z "$3" ]; then
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; exit 1; }
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_STABLE (-> $STABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local stable node version"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION) (default)$" \
|
||||
|| die "nvm alias did not contain the default local unstable node version"
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ../../../nvm.sh
|
||||
|
||||
die () { echo $@ ; cleanup ; exit 1; }
|
||||
cleanup () {
|
||||
rm -rf ../../../v0.8.1
|
||||
rm -rf ../../../v0.9.1
|
||||
}
|
||||
|
||||
mkdir ../../../v0.8.1
|
||||
mkdir ../../../v0.9.1
|
||||
|
||||
EXPECTED_STABLE="$(nvm_print_implicit_alias local stable)"
|
||||
STABLE_VERSION="$(nvm_version "$EXPECTED_STABLE")"
|
||||
|
||||
EXPECTED_UNSTABLE="$(nvm_print_implicit_alias local unstable)"
|
||||
UNSTABLE_VERSION="$(nvm_version "$EXPECTED_UNSTABLE")"
|
||||
|
||||
[ "_$STABLE_VERSION" != "_$UNSTABLE_VERSION" ] \
|
||||
|| die "stable and unstable versions are the same!"
|
||||
|
||||
nvm alias stable "$EXPECTED_UNSTABLE"
|
||||
nvm alias unstable "$EXPECTED_STABLE"
|
||||
|
||||
NVM_ALIAS_OUTPUT=$(nvm alias)
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^stable -> $EXPECTED_UNSTABLE (-> $UNSTABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'stable' alias"
|
||||
|
||||
echo "$NVM_ALIAS_OUTPUT" | \grep -e "^unstable -> $EXPECTED_STABLE (-> $STABLE_VERSION)$" \
|
||||
|| die "nvm alias did not contain the overridden 'unstable' alias"
|
||||
|
||||
cleanup
|
||||
|
|
@ -6,3 +6,6 @@ for i in $(seq 1 10)
|
|||
rm -rf "../../../v0.0.$i"
|
||||
done
|
||||
|
||||
rm -f "../../../alias/stable"
|
||||
rm -f "../../../alias/unstable"
|
||||
|
||||
|
|
Loading…
Reference in New Issue