[New] install script: Allow installation from other repository
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by nmarghetti · committed by Jordan Harband · parent f3fa157 · Browse files · 4 files·+22 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
4 files+22 added−10 removed
- tests:+14 added−6 removed
- other:+8 added−4 removed
Provenance
- Commit
4e9df33- Tree
ad6210d- Author
nmarghetti <marghettinicolas@hotmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
f3fa157
4 files changed+22 added−10 removed
modified:test/install_script/nvm_install_with_aliased_dot+4 added-2 removed
1 #!/bin/sh2 3-setup () {3+setup() {4+ # Needed to avoid to checkout the repo to the latest nvm version, losing the commits of the current PR5+ unset NVM_DIR6 shopt -s expand_aliases7 alias .=':'8 NVM_ENV=testing \. ../../install.sh > /dev/null9 }3 unmodified lines13 unalias .14 shopt -u expand_aliases15 }16 15-die () { echo "$@"; exit 1; }17+die () { echo "$@"; cleanup; exit 1; }18 19 setup20 21 nvm_do_install > /dev/null 2>&13 unmodified linesmodified:test/install_script/nvm_install_with_node_version+2 added
1 #!/bin/sh2 3 die () { echo "$@" ; exit 1; }4 5+# Needed to avoid to checkout the repo to the latest nvm version, losing the commits of the current PR6+unset NVM_DIR7 NODE_VERSION=8 \. ../../install.sh8 9 # nvm installed node 810 nvm ls 8 > /dev/null 2>&1 || die "nvm didn't install node 8"modified:test/install_script/nvm_source+8 added-4 removed
7 unmodified lines8 9 NVM_ENV=testing \. ../../install.sh10 11 # nvm_source with no parameter returns the git endpoint12-echo $(nvm_source) | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"12+[ "$(nvm_source)" = "https://github.com/nvm-sh/nvm.git" ] || die "nvm_source without arguments should return the location of the git repo"13+NVM_INSTALL_GITHUB_REPO="other-user/other-nvm" nvm_source | grep "https://github.com/other-user/other-nvm.git$" > /dev/null || die "NVM_INSTALL_GITHUB_REPO=... nvm_source without arguments should return the location of the given git repo"14 15 # nvm_source with git parameter returns the location of the nvm repo15-echo $(nvm_source "git") | grep "nvm.git$" > /dev/null || die "nvm_source without arguments should return the location of the git repo"16+[ "$(nvm_source "git")" = "https://github.com/nvm-sh/nvm.git" ] || die "nvm_source \"git\" should return the location of the git repo"17+NVM_INSTALL_GITHUB_REPO="other-user/other-nvm" nvm_source "git" | grep "https://github.com/other-user/other-nvm.git$" > /dev/null || die "NVM_INSTALL_GITHUB_REPO=... nvm_source \"git\" should return the location of the given git repo"18 19 # nvm_source with script parameter returns the location of nvm.sh18-echo $(nvm_source "script") | grep "nvm.sh$" > /dev/null || die "nvm_source \"script\" should return the location of nvm.sh"20+[ "$(nvm_source "script")" = "https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm.sh" ] || die "nvm_source \"script\" should return the location of nvm.sh"21+NVM_INSTALL_GITHUB_REPO="other-user/other-nvm" NVM_INSTALL_VERSION="v0.37.0" nvm_source "script" | grep "https://raw.githubusercontent.com/other-user/other-nvm/v0.37.0/nvm.sh$" > /dev/null || die "NVM_INSTALL_GITHUB_REPO=... NVM_INSTALL_VERSION=... nvm_source \"script\" should return the location of nvm.sh"22 23 # nvm_source with script-nvm-exec parameter returns the location of nvm-exec21-echo $(nvm_source "script-nvm-exec") | grep "nvm-exec$" > /dev/null || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"24+[ "$(nvm_source "script-nvm-exec")" = "https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm-exec" ] || die "nvm_source \"script-nvm-exec\" should return the location of nvm.sh"25+NVM_INSTALL_GITHUB_REPO="other-user/other-nvm" NVM_INSTALL_VERSION="v0.37.0" nvm_source "script-nvm-exec" | grep "https://raw.githubusercontent.com/other-user/other-nvm/v0.37.0/nvm-exec$" > /dev/null || die "NVM_INSTALL_GITHUB_REPO=... NVM_INSTALL_VERSION=... nvm_source \"script-nvm-exec\" should return the location of nvm.sh"26 27 # nvm_source with any other parameter errors out and exits28 nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"29 out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here14 unmodified linesmodified:install.sh+8 added-4 removed
40 unmodified lines41 # * The method used ("script" or "git" in the script, defaults to "git")42 # NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"43 #44 nvm_source() {45+ local NVM_GITHUB_REPO46+ NVM_GITHUB_REPO="${NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm}"47+ local NVM_VERSION48+ NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"49 local NVM_METHOD50 NVM_METHOD="$1"51 local NVM_SOURCE_URL52 NVM_SOURCE_URL="$NVM_SOURCE"53 if [ "_$NVM_METHOD" = "_script-nvm-exec" ]; then50- NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm-exec"54+ NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm-exec"55 elif [ "_$NVM_METHOD" = "_script-nvm-bash-completion" ]; then52- NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/bash_completion"56+ NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/bash_completion"57 elif [ -z "$NVM_SOURCE_URL" ]; then58 if [ "_$NVM_METHOD" = "_script" ]; then55- NVM_SOURCE_URL="https://raw.githubusercontent.com/nvm-sh/nvm/$(nvm_latest_version)/nvm.sh"59+ NVM_SOURCE_URL="https://raw.githubusercontent.com/${NVM_GITHUB_REPO}/${NVM_VERSION}/nvm.sh"60 elif [ "_$NVM_METHOD" = "_git" ] || [ -z "$NVM_METHOD" ]; then57- NVM_SOURCE_URL="https://github.com/nvm-sh/nvm.git"61+ NVM_SOURCE_URL="https://github.com/${NVM_GITHUB_REPO}.git"62 else63 echo >&2 "Unexpected value \"$NVM_METHOD\" for \$NVM_METHOD"64 return 165 fi366 unmodified lines