mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-17 19:13:43 +00:00
Compare commits
3 Commits
3bdbb20302
...
5330468628
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5330468628 | ||
![]() |
4beab63631 | ||
![]() |
c04530396e |
12
nvm.sh
12
nvm.sh
@ -503,9 +503,9 @@ $(nvm_wrap_with_color_code 'y' "${warn_text}")"
|
|||||||
}
|
}
|
||||||
|
|
||||||
nvm_process_nvmrc() {
|
nvm_process_nvmrc() {
|
||||||
local NVMRC_PATH="$1"
|
local NVMRC_PATH
|
||||||
|
NVMRC_PATH="$1"
|
||||||
local lines
|
local lines
|
||||||
local unpaired_line
|
|
||||||
|
|
||||||
lines=$(command sed 's/#.*//' "$NVMRC_PATH" | command sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | nvm_grep -v '^$')
|
lines=$(command sed 's/#.*//' "$NVMRC_PATH" | command sed 's/^[[:space:]]*//;s/[[:space:]]*$//' | nvm_grep -v '^$')
|
||||||
|
|
||||||
@ -515,8 +515,12 @@ nvm_process_nvmrc() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize key-value storage
|
# Initialize key-value storage
|
||||||
local keys=''
|
local keys
|
||||||
local values=''
|
keys=''
|
||||||
|
local values
|
||||||
|
values=''
|
||||||
|
local unpaired_line
|
||||||
|
unpaired_line=''
|
||||||
|
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
if [ -z "${line}" ]; then
|
if [ -z "${line}" ]; then
|
||||||
|
41
test/install_script/nvm_check_if_path_exists
Executable file
41
test/install_script/nvm_check_if_path_exists
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
setup () {
|
||||||
|
HOME="."
|
||||||
|
NVM_ENV=testing \. ../../install.sh
|
||||||
|
touch ".bashrc"
|
||||||
|
touch ".zshrc"
|
||||||
|
touch ".profile"
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup () {
|
||||||
|
unset HOME
|
||||||
|
unset NVM_ENV
|
||||||
|
unset NVM_DETECT_PROFILE
|
||||||
|
unset BASH_VERSION
|
||||||
|
unset ZSH_VERSION
|
||||||
|
unset -f setup cleanup die
|
||||||
|
rm -f ".bashrc" ".bash_profile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
|
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
||||||
|
|
||||||
|
setup
|
||||||
|
|
||||||
|
# check if nvm_path already exists in bashrc
|
||||||
|
NVM_DETECT_PROFILE="$(BASH_VERSION="1"; unset PROFILE; nvm_detect_profile)"
|
||||||
|
echo "export NVM_DIR="$HOME/.nvm"" > $HOME/.bashrc
|
||||||
|
OUTPUT = "$(nvm_do_install)"
|
||||||
|
EXPECTED_OUTPUT='nvm source string already in ${NVM_PROFILE}'
|
||||||
|
if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then
|
||||||
|
die "Path already exists in the profile, so should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# .zshrc should be detected for zsh
|
||||||
|
NVM_DETECT_PROFILE="$(ZSH_VERSION="1"; unset PROFILE; unset BASH_VERSION; nvm_detect_profile)"
|
||||||
|
echo "export NVM_DIR="$HOME/.nvm"" > $HOME/.zshrc
|
||||||
|
OUTPUT = "$(nvm_do_install)"
|
||||||
|
EXPECTED_OUTPUT='nvm source string already in ${NVM_PROFILE}'
|
||||||
|
if [ "${OUTPUT#*$EXPECTED_OUTPUT}" = "${OUTPUT}" ]; then
|
||||||
|
die "Path already exists in the profile, so should have returned >${EXPECTED_OUTPUT}<. Instead it returned >${OUTPUT}<"
|
||||||
|
fi
|
Loading…
x
Reference in New Issue
Block a user