2014-10-31 20:04:26 +08:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
cleanup () {
|
|
|
|
unset -f die cleanup
|
|
|
|
unset install_dir
|
|
|
|
}
|
2016-11-07 03:34:36 +08:00
|
|
|
die () { echo "$@" ; cleanup ; exit 1; }
|
2014-10-31 20:04:26 +08:00
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
NVM_ENV=testing \. ../../install.sh
|
2014-10-31 20:04:26 +08:00
|
|
|
HOME="__home__"
|
|
|
|
|
|
|
|
|
|
|
|
# NVM_DIR is set
|
2018-02-26 01:03:01 +08:00
|
|
|
NVM_DIR="some_dir"
|
2014-10-31 20:04:26 +08:00
|
|
|
install_dir=$(nvm_install_dir)
|
|
|
|
[ "_$install_dir" = "_$NVM_DIR" ] || die "nvm_install_dir should use \$NVM_DIR if it exists. Current output: $install_dir"
|
|
|
|
|
|
|
|
unset NVM_DIR
|
|
|
|
# NVM_DIR is not set
|
|
|
|
install_dir=$(nvm_install_dir)
|
2018-08-15 03:45:40 +08:00
|
|
|
fallback_dir=""
|
|
|
|
[ ! -z "$XDG_CONFIG_HOME" ] && fallback_dir="$XDG_CONFIG_HOME/nvm" || fallback_dir="$HOME/.nvm"
|
|
|
|
[ "_$install_dir" = "_$fallback_dir" ] || die "nvm_install_dir should default to \$XDG_CONFIG_DIR/.nvm. Current output: $install_dir"
|
2014-10-31 20:04:26 +08:00
|
|
|
|
|
|
|
cleanup
|