[New] adding default and alias option to nvm install

--alias=8 is equivalent to `nvm alias default 8`
--default is equivalent to `nvm alias default node`
This commit is contained in:
Kayla Altepeter 2018-10-22 08:32:29 -05:00
parent caf6208dbd
commit dd0074ccde

15
nvm.sh
View File

@ -2397,6 +2397,8 @@ nvm() {
nvm_echo ' --skip-default-packages When installing, skip the default-packages file if it exists'
nvm_echo ' --latest-npm After installing, attempt to upgrade to the latest working npm on the given node version'
nvm_echo ' --no-progress Disable the progress bar on any downloads'
nvm_echo ' --alias=<default version> After installing, set default alias to the version specified. (same as: nvm alias default <version>)'
nvm_echo ' --default After installing, set default alias to latest version available. (same as: nvm alias default node)'
nvm_echo ' nvm uninstall <version> Uninstall a version'
nvm_echo ' nvm uninstall --lts Uninstall using automatic LTS (long-term support) alias `lts/*`, if available.'
nvm_echo ' nvm uninstall --lts=<LTS name> Uninstall using automatic alias for provided LTS line, if available.'
@ -2552,6 +2554,7 @@ nvm() {
nobinary=0
noprogress=0
local LTS
local ALIAS
local NVM_UPGRADE_NPM
NVM_UPGRADE_NPM=0
while [ $# -ne 0 ]
@ -2582,12 +2585,24 @@ nvm() {
NVM_UPGRADE_NPM=1
shift
;;
--default)
ALIAS='node'
shift
;;
--alias=*)
ALIAS="${1:-}"
shift
;;
*)
break # stop parsing args
;;
esac
done
if [ -n "${ALIAS}" ]; then
nvm alias default "${ALIAS}"
fi
local provided_version
provided_version="${1-}"