#!/bin/bash
export PATH="/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/.nvm/versions/node/$(ls $HOME/.nvm/versions/node/ 2>/dev/null | tail -1)/bin"

cd /Users/gbpark/ERP-node

# Node 경로 찾기
NODE_BIN=""
if command -v node &>/dev/null; then
  NODE_BIN=$(command -v node)
elif [ -f "$HOME/.nvm/nvm.sh" ]; then
  source "$HOME/.nvm/nvm.sh"
  NODE_BIN=$(command -v node)
fi

if [ -z "$NODE_BIN" ]; then
  echo "RESULT: FAIL - node not found"
  exit 1
fi

echo "Using node: $NODE_BIN"
$NODE_BIN /Users/gbpark/ERP-node/run-e2e-runtime-test.mjs
