#!/usr/bin/env sh
set -eu
BASE_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
for arg in "$@"; do
  case "$arg" in
    --no-gui|--cli|--headless) export GHOSTSTACK_NO_GUI=1 ;;
  esac
done
if [ -x "$BASE_DIR/runtime/node" ]; then
  exec "$BASE_DIR/runtime/node" "$BASE_DIR/app.mjs"
elif command -v node >/dev/null 2>&1; then
  exec node "$BASE_DIR/app.mjs"
else
  echo "[GhostStack Shield] Node.js runtime not found in $BASE_DIR/runtime/node or PATH." >&2
  exit 1
fi
