#!/bin/sh
# Runs a composer script of the API in the development container: `sh scripts/php-qa.sh cs`.
# Only a container that is not running lets it pass (with a warning); a failing check always fails.
set -eu

container="${QA_CONTAINER:-myvolleyball_api}"

if ! docker ps --format '{{.Names}}' 2>/dev/null | grep -qx "$container"; then
  echo "php-qa: container $container is not running, 'composer $*' was not run." >&2
  exit 0
fi

exec docker exec -w /var/www/html "$container" composer "$@"
