mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-08-17 19:13:43 +00:00
Compare commits
6 Commits
0d94b29b9d
...
a62b73358d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
a62b73358d | ||
![]() |
cd22c84026 | ||
![]() |
d648a3b1ba | ||
![]() |
c74c74eb0a | ||
![]() |
9dc29fd8eb | ||
![]() |
d7058a4952 |
@ -113,3 +113,11 @@ Co-authored-by: Name Here <email@here>
|
||||
|
||||
# Where can I ask for help?
|
||||
If you have any questions, please contact [@LJHarb](mailto:ljharb@gmail.com).
|
||||
|
||||
# Developer's Certificate of Origin 1.1
|
||||
|
||||
By making a contribution to this project, I certify that:
|
||||
- The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or
|
||||
- The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or
|
||||
- The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.
|
||||
- I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.
|
||||
|
@ -296,10 +296,10 @@ nvm_detect_profile() {
|
||||
DETECTED_PROFILE="$HOME/.bash_profile"
|
||||
fi
|
||||
elif [ "${SHELL#*zsh}" != "$SHELL" ]; then
|
||||
if [ -f "$HOME/.zshrc" ]; then
|
||||
DETECTED_PROFILE="$HOME/.zshrc"
|
||||
elif [ -f "$HOME/.zprofile" ]; then
|
||||
DETECTED_PROFILE="$HOME/.zprofile"
|
||||
if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then
|
||||
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"
|
||||
elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then
|
||||
DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
2
nvm-exec
2
nvm-exec
@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
DIR="$(command cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
DIR="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
||||
|
||||
unset NVM_CD_FLAGS
|
||||
|
||||
|
8
nvm.sh
8
nvm.sh
@ -4054,8 +4054,14 @@ nvm() {
|
||||
nvm_echo "Running node ${VERSION}$(nvm use --silent "${VERSION}" && nvm_print_npm_version)"
|
||||
fi
|
||||
fi
|
||||
NODE_VERSION="${VERSION}" "${NVM_DIR}/nvm-exec" "$@"
|
||||
|
||||
NVM_EXEC="${NVM_DIR}/nvm-exec"
|
||||
if [ ! -f "${NVM_EXEC}" ]; then
|
||||
NVM_EXEC="$(dirname "${BASH_SOURCE[0]-}")/nvm-exec"
|
||||
fi
|
||||
NODE_VERSION="${VERSION}" "${NVM_EXEC}" "$@"
|
||||
;;
|
||||
|
||||
"ls" | "list")
|
||||
local PATTERN
|
||||
local NVM_NO_COLORS
|
||||
|
@ -3,12 +3,16 @@
|
||||
setup () {
|
||||
HOME="."
|
||||
NVM_ENV=testing \. ../../install.sh
|
||||
ZDOTDIR="$HOME/zdotdir"
|
||||
mkdir -p zdotdir
|
||||
touch ".bashrc"
|
||||
touch ".bash_profile"
|
||||
touch ".zprofile"
|
||||
touch ".zshrc"
|
||||
touch ".profile"
|
||||
touch "test_profile"
|
||||
touch "zdotdir/.zshrc"
|
||||
touch "zdotdir/.zprofile"
|
||||
}
|
||||
|
||||
cleanup () {
|
||||
@ -17,7 +21,9 @@ cleanup () {
|
||||
unset NVM_DETECT_PROFILE
|
||||
unset SHELL
|
||||
unset -f setup cleanup die
|
||||
unset ZDOTDIR
|
||||
rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&1
|
||||
rm -rf zdot>&1
|
||||
}
|
||||
|
||||
die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }
|
||||
@ -46,8 +52,14 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||
die "nvm_detect_profile ignored \$PROFILE"
|
||||
fi
|
||||
|
||||
# .zshrc should be detected for zsh
|
||||
# zdotdir/.zshrc should be detected for zsh
|
||||
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||
die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"
|
||||
fi
|
||||
|
||||
# .zshrc should be detected for zsh
|
||||
NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||
die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"
|
||||
fi
|
||||
@ -58,7 +70,6 @@ if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then
|
||||
die "nvm_detect_profile ignored \$PROFILE"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Confirm $PROFILE is only returned when it points to a valid file
|
||||
#
|
||||
@ -102,16 +113,30 @@ if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then
|
||||
die "nvm_detect_profile should have selected .bash_profile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zprofile if file exists
|
||||
# Otherwise, it should favor zdotdir/.zprofile if file exists
|
||||
rm ".bash_profile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then
|
||||
die "nvm_detect_profile should have selected zdotdir/.zprofile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zprofile if file exists
|
||||
rm "zdotdir/.zprofile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then
|
||||
die "nvm_detect_profile should have selected .zprofile"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
# Otherwise, it should favor zdotdir/.zshrc if file exists
|
||||
rm ".zprofile"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then
|
||||
die "nvm_detect_profile should have selected zdotdir/.zshrc"
|
||||
fi
|
||||
|
||||
# Otherwise, it should favor .zshrc if file exists
|
||||
rm "zdotdir/.zshrc"
|
||||
NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"
|
||||
if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then
|
||||
die "nvm_detect_profile should have selected .zshrc"
|
||||
fi
|
||||
|
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
die () { echo "$@" ; exit 1; }
|
||||
|
||||
INSTPATH="$(mktemp -p "$(pwd)" -d)"
|
||||
trap 'test ! -z "${INSTPATH-}" && test -d "$INSTPATH" && rm -rf "$INSTPATH"' EXIT
|
||||
declare -x NVM_DIR=$INSTPATH
|
||||
\. ../../../nvm.sh
|
||||
|
||||
nvm install --lts || die 'nvm install --lts failed'
|
||||
nvm exec --lts npm --version || die "`nvm exec` failed to run"
|
||||
declare -x NODE_VERSION="$(nvm exec --lts --silent node --version)"
|
||||
|
||||
ln -s ../../../../nvm-exec "$INSTPATH/nvm-exec" || die "failed to create a symlink to $INSTPATH/"
|
||||
"$INSTPATH/nvm-exec" npm ls > /dev/null || die "`nvm exec` failed to run using nvm-exec helper"
|
||||
|
Loading…
x
Reference in New Issue
Block a user