Skip to content
Myr

Merge pull request #567 from xcambar/nvm_source

Before adoption: this commit came in with the history the project adopted, so no landing records it.

[install script] Refactors NVM_SOURCE

authored by Jordan Harband · committed by Jordan Harband · parents e28a257, 516e553 · Browse files · 2 files+69 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+69 added−10 removed

  • tests:+37 added−0 removed
  • other:+32 added−10 removed

2 files+69 added−10 removed

added:test/install_script/nvm_source+37 added
1#!/bin/sh23cleanup () {4 unset -f die cleanup5 unset NVM_SOURCE out6}7die () { echo $@ ; cleanup ; exit 1; }89NVM_ENV=testing . ../../install.sh1011# nvm_source with no parameter returns the git endpoint12echo $(nvm_source) | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" 1314# nvm_source with git parameter returns the location of the nvm repo15echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo" 1617# nvm_source with script parameter returns the location of nvm.sh18echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"1920# nvm_source with any other parameter errors out and exits21nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"22out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here23[ -z "$out" ] && die "nvm_source with invalid parameter should error out"2425#nvm_source should always return NVM_SOURCE no matter the parameters26NVM_SOURCE="my_location"27out=$(nvm_source)28[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""29out=$(nvm_source "git")30[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\""31out=$(nvm_source "script")32[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""33out=$(nvm_source "anything")34[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""3536cleanup37
modified:install.sh+32 added-10 removed