#!/bin/sh
# GoLuzzy launcher — delegates to real binary or triggers install
set -e

BIN_DIR="$(cd "$(dirname "$0")" && pwd)"
REAL="$BIN_DIR/goluzzy-real"

if [ -f "$REAL" ]; then
    exec "$REAL" "$@"
fi

# Binary not found — likely this is the first npm install
# The postinstall script should have downloaded it
echo "GoLuzzy binary not found. Running postinstall..."
cd "$(dirname "$BIN_DIR")"
node scripts/postinstall.js

if [ -f "$REAL" ]; then
    exec "$REAL" "$@"
else
    echo "Installation failed. Please try: npm install -g goluzzy"
    exit 1
fi
