#!/bin/sh
set -e

EMAIL_GEN_ROOT="${EMAIL_GEN_ROOT:-/workspace/email-gen}"

# Install deps inside container if needed (host node_modules may be incompatible)
if [ -f "$EMAIL_GEN_ROOT/package.json" ]; then
  echo "Installing email-gen dependencies..."
  cd "$EMAIL_GEN_ROOT"
  npm install 2>&1
  echo "Dependencies ready."
fi

exec node /app/server.js
