[Fix] ensure --reinstall-packages-from has a version number.
Fixes #1760.
parent
2850e65b62
commit
0e3bb2cc47
8
nvm.sh
8
nvm.sh
|
@ -2558,8 +2558,16 @@ nvm() {
|
|||
case "$1" in
|
||||
--reinstall-packages-from=*)
|
||||
PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 27-)"
|
||||
if [ -z "${PROVIDED_REINSTALL_PACKAGES_FROM}" ]; then
|
||||
nvm_err 'If --reinstall-packages-from is provided, it must point to an installed version of node.'
|
||||
return 6
|
||||
fi
|
||||
REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
|
||||
;;
|
||||
--reinstall-packages-from)
|
||||
nvm_err 'If --reinstall-packages-from is provided, it must point to an installed version of node using `=`.'
|
||||
return 6
|
||||
;;
|
||||
--copy-packages-from=*)
|
||||
PROVIDED_REINSTALL_PACKAGES_FROM="$(nvm_echo "$1" | command cut -c 22-)"
|
||||
REINSTALL_PACKAGES_FROM="$(nvm_version "$PROVIDED_REINSTALL_PACKAGES_FROM")" ||:
|
||||
|
|
|
@ -39,4 +39,18 @@ set -e
|
|||
[ $INSTALL_EXIT_CODE -eq 4 ] \
|
||||
|| die ""nvm install --reinstall-packages-from" should exit with code 4 when given the same version, got $INSTALL_EXIT_CODE"
|
||||
|
||||
set +ex # needed for stderr
|
||||
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from 2>&1)"
|
||||
set -ex
|
||||
EXPECTED_ERROR_MSG='If --reinstall-packages-from is provided, it must point to an installed version of node using `=`.'
|
||||
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||
|
||||
set +ex # needed for stderr
|
||||
INSTALL_ERROR_MSG="$(nvm install v0.10.5 --reinstall-packages-from= 2>&1)"
|
||||
set -ex
|
||||
EXPECTED_ERROR_MSG="If --reinstall-packages-from is provided, it must point to an installed version of node."
|
||||
[ "~$INSTALL_ERROR_MSG" = "~$EXPECTED_ERROR_MSG" ] \
|
||||
|| die ""nvm install --reinstall-packages-from" should fail when given an uninstalled version: expected '$EXPECTED_ERROR_MSG', got '$INSTALL_ERROR_MSG'"
|
||||
|
||||
cleanup
|
||||
|
|
Loading…
Reference in New Issue