Skip to content
Myr

nvm_source

This file

Path

test/install_script/nvm_source

43 lines · 3.0 KiB

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than 5c12680 point at it.

[Dev Deps] update `markdown-link-check`Jordan Harbandbefore adoption5c12680

lines 1–43why, one step back
1#!/bin/sh
23cleanup () {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 endpoint12[ "$(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 repo16[ "$(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.sh20[ "$(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-exec24[ "$(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 here30[ -z "$out" ] && die "nvm_source with invalid parameter should error out"3132#nvm_source should always return NVM_SOURCE no matter the parameters33export NVM_SOURCE="my_location"34out=$(nvm_source)35[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""36out=$(nvm_source "git")37[ "_$out" = "_my_location" ] || die "nvm_source git should have returned \$NVM_SOURCE. Got \"$out\""38out=$(nvm_source "script")39[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""40out=$(nvm_source "anything")41[ "_$out" = "_my_location" ] || die "nvm_source script should have returned \$NVM_SOURCE. Got \"$out\""4243cleanup