#! /usr/bin/env bash
#
# Setup script for building and testing the project.
# Assumes opam is installed.
#
set -eu

# On Windows, sourcing the output of 'opam env' fails badly, causing
# the 'opam' command to no longer be found by the shell.
# Instead, use 'opam exec -- <command>' where needed.
#eval "$(opam env)"

opam update

# This should not install 'testo' even though it's a dependency of 'testo-lwt'.
# Pass '-y' to 'setup' to answer 'yes' to all questions from opam.
#
opam install --deps-only --with-test --with-dev-setup "$@" \
  ./testo-diff.opam \
  ./testo-util.opam \
  ./testo.opam \
  ./testo-lwt.opam

# Install pre-commit hooks. See https://pre-commit.com/
# but don't bother if we're on Windows
if [[ -z "${SYSTEMROOT+x}" ]]; then
  # We're not on Windows
  pre-commit install
fi
