2022-06-13 19:54:47 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-03-18 13:46:05 +00:00
|
|
|
|
|
|
|
# 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
|
2022-06-13 19:54:47 +00:00
|
|
|
shfmt -i 4 -ln bash -s "${file}" > "${tmpfile}"
|
|
|
|
mv "${tmpfile}" "${file}"
|
2022-03-18 13:46:05 +00:00
|
|
|
done
|
2022-06-13 19:54:47 +00:00
|
|
|
rm -f "${tmpfile}"
|
2022-03-18 13:46:05 +00:00
|
|
|
|
|
|
|
# Undo the changes to the Bats scripts in-place so that they work with Bats
|
|
|
|
perl -pi -e 's/^\{\R//; s/(\@test.*$)/$1 {/' ./*.bats
|