#! /usr/bin/env bash
#
# Fix opam files generated by 'dune build' from 'dune-project'
# prior to release. Ideally, we shouldn't need this.
#
set -eu -o pipefail

sed_in_place() {
  # This should work both with GNU sed and BSD sed
  sed -i.sed-tmp "$@"
  rm -f *.sed-tmp
}

# Not sure why @runtest is inserted into some opam files and not others.
# We remove it so as to not have opam-repository's CI run into errors
# due to missing dependencies for the target languages (Python, Java, etc.)
sed_in_place '/"@runtest" {with-test}/d' *.opam
