diff --git a/.ci/format/apply_shfmt_bats.sh b/.ci/format/apply_shfmt_bats.sh new file mode 100755 index 0000000000000000000000000000000000000000..c19acb36328f0521fa86298dfe9570eb03feeb1c --- /dev/null +++ b/.ci/format/apply_shfmt_bats.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [ -z "${SHFMT_BIN}" ]; then + SHFMT_BIN="shfmt" +fi + +if ! command -v "${SHFMT_BIN}" >/dev/null 2>&1; then + echo "ERROR: Binary '${SHFMT_BIN}' does not exist, please set the environment variable SHFMT_BIN to the correct shfmt version." + exit 1 +fi + +format_command="${SHFMT_BIN} -w -ln bats -i 4" + +apply_format_script="$(dirname "${BASH_SOURCE[0]}")/apply_format.sh" + +files_regex=".*\.bats$" + +if ! "${apply_format_script}" --format-command "${format_command}" --files-regex "${files_regex}" "$@"; then + echo "ERROR: Executing '${apply_format_script}' failed." + exit 1 +fi