Skip to content
Myr

[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

4 files+22 added−10 removed

modified:test/install_script/nvm_install_with_aliased_dot+4 added-2 removed
1#!/bin/sh23setup () {3setup() {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 lines
13 unalias .14 shopt -u expand_aliases15}1615die () { echo "$@"; exit 1; }17die () { echo "$@"; cleanup; exit 1; }1819setup2021nvm_do_install > /dev/null 2>&1
3 unmodified lines
modified:test/install_script/nvm_install_with_node_version+2 added
1#!/bin/sh23die () { echo "$@" ; exit 1; }45# Needed to avoid to checkout the repo to the latest nvm version, losing the commits of the current PR6unset NVM_DIR7NODE_VERSION=8 \. ../../install.sh89# nvm installed node 810nvm 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 lines
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"12[ "$(nvm_source)" = "https://github.com/nvm-sh/nvm.git" ] || die "nvm_source without arguments should return the location of the git repo"13NVM_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"1415# 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"16[ "$(nvm_source "git")" = "https://github.com/nvm-sh/nvm.git" ] || die "nvm_source \"git\" should return the location of the git repo"17NVM_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"1819# 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"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"21NVM_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"2223# nvm_source with script-nvm-exec parameter returns the location of nvm-exec21echo $(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"25NVM_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"2627# nvm_source with any other parameter errors out and exits28nvm_source "anything" 2> /dev/null && die "nvm_source with invalid parameter should exit"29out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
14 unmodified lines
modified:install.sh+8 added-4 removed
40 unmodified lines
41# * 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#44nvm_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 fi
366 unmodified lines