Files
would-reformat/prettier.sh
2023-09-18 16:44:26 -06:00

29 lines
536 B
Bash
Executable File

#!/bin/bash
set -uo pipefail
IFS=$'\n\t'
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$DIR/_reformat-common.bash"
file="$1"
wrflog running against file $file
out=$(npx prettier --check $file 2>&1 >/dev/null)
if [[ x"$WOULD_REFORMAT" = x"would_reformat" ]] ; then
out=$(npx prettier --check $file 2>&1 >/dev/null)
retval="$?"
exit "$retval"
fi
if [[ x"$WOULD_REFORMAT" = x"do_reformat" ]] ; then #
out=$(npx prettier --write $file 2>&1 >/dev/null)
retval="$?"
exit "$retval"
fi
exit 255