Skip to content

Commit

Permalink
[Fix] install.sh: when NVM_INSTALL_GITHUB_REPO is set, issue a wa…
Browse files Browse the repository at this point in the history
…rning

This should only annoy those testing their PRs; real users should never set this env var
  • Loading branch information
ljharb committed Nov 3, 2023
1 parent d02ddca commit 4bdd57b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,28 @@ nvm_profile_is_bash_or_zsh() {
#
# Outputs the location to NVM depending on:
# * The availability of $NVM_SOURCE
# * The presence of $NVM_INSTALL_GITHUB_REPO
# * The method used ("script" or "git" in the script, defaults to "git")
# NVM_SOURCE always takes precedence unless the method is "script-nvm-exec"
#
nvm_source() {
local NVM_GITHUB_REPO
NVM_GITHUB_REPO="${NVM_INSTALL_GITHUB_REPO:-nvm-sh/nvm}"
if [ "${NVM_GITHUB_REPO}" != 'nvm-sh/nvm' ]; then
{ nvm_echo >&2 "$(cat)" ; } << EOF
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE REPO IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
The default repository for this install is \`nvm-sh/nvm\`,
but the environment variables \`\$NVM_INSTALL_GITHUB_REPO\` is
currently set to \`${NVM_GITHUB_REPO}\`.
If this is not intentional, interrupt this installation and
verify your environment variables.
EOF
fi
local NVM_VERSION
NVM_VERSION="${NVM_INSTALL_VERSION:-$(nvm_latest_version)}"
local NVM_METHOD
Expand Down
2 changes: 1 addition & 1 deletion test/install_script/nvm_source
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ out=$(nvm_source "anything" 2>&1 >/dev/null) || : #Saving the process here
[ -z "$out" ] && die "nvm_source with invalid parameter should error out"

#nvm_source should always return NVM_SOURCE no matter the parameters
NVM_SOURCE="my_location"
export NVM_SOURCE="my_location"
out=$(nvm_source)
[ "_$out" = "_my_location" ] || die "nvm_source without arguments should have returned \$NVM_SOURCE. Got \"$out\""
out=$(nvm_source "git")
Expand Down

0 comments on commit 4bdd57b

Please sign in to comment.