diff --git a/deploy.sh b/deploy.sh index 83ddfd7..958ab1c 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,6 +9,28 @@ NC="\033[0m" log() { echo -e "${GREEN}[$(date +'%Y-%m-%d %H:%M:%S')] $*${NC}"; } err() { echo -e "${RED}[$(date +'%Y-%m-%d %H:%M:%S')] $*${NC}" 1>&2; } +ensure_command() { + local cmd="$1" + command -v "$cmd" >/dev/null 2>&1 +} + +bootstrap_node() { + # In non-interactive SSH sessions, node/npm might not be on PATH (e.g. nvm in .bashrc). + if ensure_command npm && ensure_command node; then + return 0 + fi + if [ -s "$HOME/.nvm/nvm.sh" ]; then + # shellcheck disable=SC1090 + . "$HOME/.nvm/nvm.sh" + # Prefer default alias if configured, otherwise keep current. + nvm use --silent default >/dev/null 2>&1 || true + fi +} + +bootstrap_node +if ! ensure_command git; then err "git not found in PATH"; exit 127; fi +if ! ensure_command npm; then err "npm not found in PATH"; exit 127; fi + log "Fetching latest changes..." git fetch --all --prune || { err "git fetch failed"; exit 1; }