github.com/crowdsecurity/crowdsec@v1.6.1/test/bats/reformat (about)

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