🐛 Finally get Node.js installs working!!

This commit is contained in:
Marley Rae 2024-01-25 13:14:28 -08:00
parent fca3768cb0
commit 997d37765a
3 changed files with 11 additions and 41 deletions

View file

@ -1,14 +1,13 @@
#!/usr/bin/env bash
# vim:set ft=bash:
#!/usr/bin/env zsh
cd "$(dirname "${BASH_SOURCE[0]}")" \
cd "$(dirname ${(%):-%x})" \
&& source "../script/utils.sh"
if ! [[ -d "~/.zsh-plugins/zsh-nvm" ]]; then
execute \
"git clone https://github.com/lukechilds/zsh-nvm.git ~/.zsh-plugins/zsh-nvm" \
"zsh-nvm"
fi
execute \
"if ! [ -d \"$HOME/.zsh-plugins/zsh-nvm\" ]; then git clone https://github.com/lukechilds/zsh-nvm.git ~/.zsh-plugins/zsh-nvm; fi" \
"zsh-nvm"
source "./nvm.zsh"
execute "nvm install lts/iron" "Node.js 20.x"

View file

@ -1,32 +1,5 @@
#!/usr/bin/env zsh
export NVM_COMPLETION=true
export NVM_AUTO_USE=true
source ~/.zsh-plugins/zsh-nvm/zsh-nvm.plugin.zsh
# Call nvm use automatically whenever a directory containing .nvmrc is entered.
autoload -U add-zsh-hook
function load-nvmrc()
{
local nvmrc_path
nvmrc_path="$(nvm_find_nvmrc)"
if [[ -n "$nvmrc_path" ]]; then
local nvmrc_node_version
nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
if [[ "$nvmrc_node_version" == "N/A" ]]; then
nvm install
elif [[ "$nvmrc_node_version" != "$(nvm version)" ]]; then
nvm use
fi
elif [[ -n "$(PWD=$OLDPWD nvm_find_nvmrc)" ]] \
&& [[ "$(nvm version)" != "$(nvm version default)" ]]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
add-zsh-hook chpwd load-nvmrc
load-nvmrc

View file

@ -38,11 +38,9 @@ ask_for_sudo()
print_in_color()
{
string=$(echo "$1" | tr -s " ")
printf "%b" \
"$(tput setaf "$2" 2> /dev/null)" \
"$string" \
"$1" \
"$(tput sgr0 2> /dev/null)"
}
@ -164,7 +162,7 @@ show_spinner()
tput sc
while kill -0 "$PID" &> /dev/null; do
frame_text=" [${FRAMES:i++%NUMBER_OF_FRAMES:1}] $MSG"
frame_text=" [${FRAMES:$((i++%NUMBER_OF_FRAMES)):1}] $MSG"
# Print frame text.
printf "%s" "$frame_text"
@ -193,7 +191,7 @@ is_git_repository()
set_trap()
{
trap -p "$1" | grep "$2" &> /dev/null \
|| trap '$2' "$1"
|| trap "$2" "$1"
}
kill_all_subproccesses()