1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/bin/env bash
#
# format.sh
#
# Usage:
# uv run --frozen etc/shfmt-format-all.sh
#
# This script is meant to be run from the project root directory.
set -o errexit
set -o pipefail
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
root_dir="$(cd "${script_dir:?}/.." && pwd)"
command -v find >/dev/null
include=(
"${root_dir:?}/.evergreen"
"${root_dir:?}/src"
"${root_dir:?}/tools"
)
exclude=(
"${root_dir:?}/.evergreen/scripts/uv-installer.sh"
)
mapfile -t files < <(find "${include[@]:?}" -name '*.sh' -type f | grep -v "${exclude[@]:?}")
for file in "${files[@]:?}"; do
uv run --frozen --group format-scripts shfmt -i 2 -w "${file:?}"
done
|