Skip to content

Commit

Permalink
Don't bother testing --install option on source, or supporting it, un…
Browse files Browse the repository at this point in the history
…less the shell supports passing options upon sourcing.
  • Loading branch information
ljharb committed Dec 26, 2014
1 parent 3df0cae commit 9a4e906
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1102,7 +1102,7 @@ nvm() {
echo "0.21.0"
;;
"unload" )
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to > /dev/null 2>&1
unset -f nvm nvm_print_versions nvm_checksum nvm_ls_remote nvm_ls nvm_remote_version nvm_version nvm_rc_version nvm_version_greater nvm_version_greater_than_or_equal_to nvm_supports_source_options > /dev/null 2>&1
unset RC_VERSION NVM_NODEJS_ORG_MIRROR NVM_DIR NVM_CD_FLAGS > /dev/null 2>&1
;;
* )
Expand All @@ -1111,7 +1111,11 @@ nvm() {
esac
}

if [ "_$1" = "_--install" ]; then
nvm_supports_source_options() {
[ "_$(echo 'echo $1' | . /dev/stdin yes)" = "_yes" ]
}

if nvm_supports_source_options && [ "_$1" = "_--install" ]; then
VERSION="$(nvm_alias default 2>/dev/null)"
if [ -n "$VERSION" ]; then
nvm install "$VERSION" >/dev/null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/sh

die () { echo $@ ; exit 1; }
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

echo '0.10.2' > ../../.nvmrc || die 'creation of .nvmrc failed'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/sh

die () { echo $@ ; exit 1; }
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

echo '0.10.2' > ../../alias/default || die 'creation of default alias failed'

Expand Down

0 comments on commit 9a4e906

Please sign in to comment.