#!/usr/bin/env bash set -o errexit set -o nounset set -o pipefail if [[ -n "${BUILD_WORKSPACE_DIRECTORY:-}" ]]; then # Running inside bazel echo "Updating gomock..." >&2 elif ! command -v bazel &>/dev/null; then echo "Install bazel via 'just hack/bazelisk'" >&2 exit 1 else echo "This script should be ran via a Bazel target" exit 1 fi go=$(realpath "$1") gomock="$(realpath "$2")" dir=$3 PATH=$(dirname "$gomock"):$(dirname "$go"):$PATH # https://github.com/koalaman/shellcheck/wiki/SC2155 export PATH REPO_ROOT=${BUILD_WORKSPACE_DIRECTORY} cd "${REPO_ROOT}/${dir}" echo "Generating code from ${REPO_ROOT}/${dir}" "$go" generate ./...