crowdsec/tests/bats/reformat

18 lines
524 B
Text
Raw Normal View History

#!/usr/bin/env bash
# from https://github.com/bats-core/bats-core/issues/192#issuecomment-528315083
# thanks Sean Leather
# Rewrite the Bats scripts in-place to look more like Bash scripts to shfmt
perl -pi -e 's/^(\@test.*) \{$/$1\n{/' ./*.bats
tmpfile=$(mktemp)
for file in *bats; do
shfmt -i 4 -ln bash -s "${file}" > "${tmpfile}"
mv "${tmpfile}" "${file}"
done
rm -f "${tmpfile}"
# Undo the changes to the Bats scripts in-place so that they work with Bats
perl -pi -e 's/^\{\R//; s/(\@test.*$)/$1 {/' ./*.bats