#!/bin/bash

if ! command -v bun &> /dev/null
then
    echo "Bun is not installed. Please install it from https://bun.sh"
    exit 1
fi

if ! command -v entr &> /dev/null
then
    echo "entr is not installed. Installing entr..."
    # For Debian/Ubuntu-based systems
    if [[ -x "$(command -v apt)" ]]; then
        sudo apt update && sudo apt install entr -y
    # For Red Hat-based systems
    elif [[ -x "$(command -v yum)" ]]; then
        sudo yum install entr -y
    # For macOS with Homebrew
    elif [[ -x "$(command -v brew)" ]]; then
        brew install entr
    else
        echo "Package manager not supported. Please install entr manually."
        exit 1
    fi
fi

echo "Running 'find src/ | entr -s \"bunx lightningcss-cli --minify --bundle src/main.css -o dragon.css\"'..."
find src/ | entr -s 'bunx lightningcss-cli --minify --bundle src/main.css -o dragon.css'
