#!/usr/bin/env sh
set -eu

ROOT_DIR="$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"

if command -v go >/dev/null 2>&1; then
  (cd "$ROOT_DIR/services/core" && go vet ./...)
else
  echo "skip services/core: go not found"
fi

if command -v flutter >/dev/null 2>&1 && [ -f "$ROOT_DIR/apps/client/pubspec.yaml" ]; then
  (cd "$ROOT_DIR/apps/client" && flutter analyze --no-fatal-infos)
else
  echo "skip apps/client: flutter not found or app not generated"
fi

