Files
would-reformat/examples/php
2023-09-30 20:38:00 -06:00

37 lines
731 B
Bash

#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
## This usually isn't necessary, but if you need to use wrflog this
## is how you get it:
# source "$WF_ROOT/_reformat-common.bash"
if [[ "$WOULD_REFORMAT" = "would_reformat" ]] ; then
set +e
out=$(php $DIR/.././vendor/bin/pint --test "$1")
retval="$?"
set -e
# unfortunately, pint doesn't distinguish between files with
# syntax errors and files that are merely misformatted
echo "$out"
exit "$retval"
fi
if [[ "$WOULD_REFORMAT" = "do_reformat" ]] ; then
set +e
out=$(php $DIR/.././vendor/bin/pint "$1")
retval="$?"
set -e
echo "$out"
exit "$retval"
fi
exit 255