Files
would-reformat/prettier.sh
2023-09-20 07:09:45 -06:00

27 lines
485 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
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