2021-11-06 02:39:38 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
if ! which black &>/dev/null; then
|
|
|
|
echo "Black is required to format this project"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-11-06 13:34:33 -04:00
|
|
|
if [[ $1 == "check" ]]; then
|
|
|
|
check="--check"
|
|
|
|
fi
|
|
|
|
|
2021-11-06 03:16:02 -04:00
|
|
|
pushd $( git rev-parse --show-toplevel ) &>/dev/null
|
|
|
|
|
2021-11-06 03:10:17 -04:00
|
|
|
echo "Formatting..."
|
2021-11-06 13:34:33 -04:00
|
|
|
black --safe ${check} --exclude api-daemon/migrations .
|
2021-11-06 02:39:38 -04:00
|
|
|
ret=$?
|
|
|
|
if [[ $ret -eq 0 ]]; then
|
|
|
|
echo "Successfully formatted project!"
|
|
|
|
fi
|
2021-11-06 03:16:02 -04:00
|
|
|
|
|
|
|
popd &>/dev/null
|
2021-11-06 02:39:38 -04:00
|
|
|
exit $ret
|