#!/bin/sh
set -e

# Ensure node_modules are in sync with package.json
# This handles the case where the anonymous volume has stale dependencies
if [ ! -d "node_modules" ] || [ "package.json" -nt "node_modules" ]; then
    echo "Installing npm packages..."
    npm install --network-timeout=600000 --retry 3
fi

# Execute the CMD
exec "$@"
