31 lines
1004 B
Bash
Executable File
31 lines
1004 B
Bash
Executable File
#!/usr/bin/env bash
|
|
# 35-nvm — Node Version Manager + Node LTS.
|
|
|
|
step_name="nvm"
|
|
step_desc="nvm into ~/.nvm, install Node LTS"
|
|
step_run="run_nvm"
|
|
|
|
run_nvm() {
|
|
log "installing nvm"
|
|
export NVM_DIR="${NVM_DIR:-$HOME/.nvm}"
|
|
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
|
|
ok "nvm already present at $NVM_DIR"
|
|
else
|
|
# fetch the install script at a pinned NVM version (update here to upgrade)
|
|
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash \
|
|
|| { warn "nvm install failed"; return; }
|
|
ok "nvm installed to $NVM_DIR"
|
|
fi
|
|
|
|
# shellcheck disable=SC1091
|
|
source "$NVM_DIR/nvm.sh"
|
|
if command -v nvm >/dev/null 2>&1; then
|
|
log "installing Node LTS via nvm"
|
|
nvm install --lts || warn "nvm install --lts failed"
|
|
nvm use --lts 2>/dev/null || true
|
|
nvm alias default 'lts/*' 2>/dev/null || true
|
|
command -v node >/dev/null 2>&1 && ok "node $(node -v) active"
|
|
else
|
|
warn "nvm.sh sourced but nvm not available — check $NVM_DIR"
|
|
fi
|
|
} |