From 055a58cc691f87fd44e00a8a45ca13493384cecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20W=C3=B6lzer?= <martin@libclapp.org> Date: Mon, 16 Sep 2024 20:48:56 +0200 Subject: [PATCH] .ci/format/apply_shfmt_bats.sh: introduced file --- .ci/format/apply_shfmt_bats.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 .ci/format/apply_shfmt_bats.sh diff --git a/.ci/format/apply_shfmt_bats.sh b/.ci/format/apply_shfmt_bats.sh new file mode 100755 index 00000000..c19acb36 --- /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 -- GitLab