mirror of
https://github.com/nvm-sh/nvm.git
synced 2025-05-11 14:51:49 +00:00
Update install.sh
This commit is contained in:
parent
28e72a8ff2
commit
a5cf57a736
68
install.sh
68
install.sh
@ -366,15 +366,6 @@ nvm_check_global_modules() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Function to get current node version
|
|
||||||
get_node_version() {
|
|
||||||
if command -v node >/dev/null 2>&1; then
|
|
||||||
echo "(node $(node -v))"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
nvm_do_install() {
|
nvm_do_install() {
|
||||||
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
if [ -n "${NVM_DIR-}" ] && ! [ -d "${NVM_DIR}" ]; then
|
||||||
if [ -e "${NVM_DIR}" ]; then
|
if [ -e "${NVM_DIR}" ]; then
|
||||||
@ -471,21 +462,14 @@ nvm_do_install() {
|
|||||||
command printf "${COMPLETION_STR}"
|
command printf "${COMPLETION_STR}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Source nvm
|
# Define the code to add to the shell configuration file
|
||||||
# shellcheck source=/dev/null
|
CODE=$(cat <<'EOF'
|
||||||
\. "$(nvm_install_dir)/nvm.sh"
|
# Function to get current node version
|
||||||
|
get_node_version() {
|
||||||
nvm_check_global_modules
|
if command -v node >/dev/null 2>&1; then
|
||||||
|
echo "(node $(node -v))"
|
||||||
nvm_install_node
|
|
||||||
|
|
||||||
nvm_reset
|
|
||||||
|
|
||||||
nvm_echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
|
|
||||||
command printf "${SOURCE_STR}"
|
|
||||||
if ${BASH_OR_ZSH} ; then
|
|
||||||
command printf "${COMPLETION_STR}"
|
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Update prompt based on the shell (bash or zsh)
|
# Update prompt based on the shell (bash or zsh)
|
||||||
if [ "$SHELL" = "/bin/bash" ] || [ "$SHELL" = "/usr/bin/bash" ]; then
|
if [ "$SHELL" = "/bin/bash" ] || [ "$SHELL" = "/usr/bin/bash" ]; then
|
||||||
@ -509,6 +493,44 @@ nvm_do_install() {
|
|||||||
# Enable prompt substitution in zsh
|
# Enable prompt substitution in zsh
|
||||||
setopt promptsubst
|
setopt promptsubst
|
||||||
fi
|
fi
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
|
||||||
|
# Determine the shell configuration file based on the current shell
|
||||||
|
case "$SHELL" in
|
||||||
|
*/bash)
|
||||||
|
CONFIG_FILE="$HOME/.bashrc"
|
||||||
|
;;
|
||||||
|
*/zsh)
|
||||||
|
CONFIG_FILE="$HOME/.zshrc"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported shell: $SHELL"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Append the code to the appropriate configuration file
|
||||||
|
append_to_file "$CONFIG_FILE" "$CODE"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Source nvm
|
||||||
|
# shellcheck source=/dev/null
|
||||||
|
\. "$(nvm_install_dir)/nvm.sh"
|
||||||
|
|
||||||
|
nvm_check_global_modules
|
||||||
|
|
||||||
|
nvm_install_node
|
||||||
|
|
||||||
|
nvm_reset
|
||||||
|
|
||||||
|
nvm_echo "=> Close and reopen your terminal to start using nvm or run the following to use it now:"
|
||||||
|
command printf "${SOURCE_STR}"
|
||||||
|
if ${BASH_OR_ZSH} ; then
|
||||||
|
command printf "${COMPLETION_STR}"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user