2014-12-27 04:19:35 +08:00
|
|
|
#!/bin/sh
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../common.sh
|
2014-12-27 04:19:35 +08:00
|
|
|
|
2016-11-07 03:34:36 +08:00
|
|
|
die () { echo "$@" ; exit 1; }
|
2014-12-27 04:19:55 +08:00
|
|
|
supports_source_options () {
|
|
|
|
[ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ]
|
|
|
|
}
|
|
|
|
|
|
|
|
if ! supports_source_options; then
|
|
|
|
echo 'this shell does not support passing options on sourcing'
|
|
|
|
exit 0;
|
|
|
|
fi
|
2014-12-27 04:19:35 +08:00
|
|
|
|
|
|
|
echo '0.10.2' > ../../alias/default || die 'creation of default alias failed'
|
|
|
|
|
|
|
|
echo 'sourcing nvm with --install...'
|
|
|
|
|
2016-11-04 13:15:18 +08:00
|
|
|
\. ../../nvm.sh --install
|
2014-12-27 04:19:35 +08:00
|
|
|
EXIT_CODE="$(echo $?)"
|
|
|
|
|
|
|
|
echo 'sourcing complete.'
|
|
|
|
|
|
|
|
nvm_version 0.10.2 >/dev/null 2>&1 || die "v0.10.2 not installed: $(nvm ls)"
|
|
|
|
|
|
|
|
[ "_$EXIT_CODE" = "_0" ] || die "sourcing returned nonzero exit code: $EXIT_CODE"
|
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
NVM_LS_CURRENT="$(nvm ls current | strip_colors | command grep -o v0.10.2)"
|
2014-12-27 04:19:35 +08:00
|
|
|
[ "_$NVM_LS_CURRENT" = '_v0.10.2' ] || die "'nvm ls current' did not return '-> v0.10.2', got '$NVM_LS_CURRENT'"
|
|
|
|
|
2016-04-28 08:05:33 +08:00
|
|
|
NVM_ALIAS_DEFAULT="$(nvm alias default | strip_colors)"
|
2014-12-27 04:19:35 +08:00
|
|
|
[ "_$NVM_ALIAS_DEFAULT" = "_default -> 0.10.2 (-> v0.10.2)" ] \
|
|
|
|
|| die "'nvm alias default did not return 'default -> 0.10.2 (-> v0.10.2)', got '$NVM_ALIAS_DEFAULT'"
|
|
|
|
|