Files
scenarionet/format.sh

21 lines
668 B
Bash
Raw Permalink Normal View History

2023-05-06 22:10:58 +01:00
#!/usr/bin/env bash
# Usage: at the root dir >> bash scripts/format.sh
# Check yapf version.
ver=$(yapf --version)
if ! echo $ver | grep -q 0.30.0; then
echo "Wrong YAPF version installed: 0.30.0 is required, not $ver. Please install via `pip install yapf==0.30.0`"
exit 1
fi
yapf --in-place --recursive -p --verbose --style .style.yapf scenarionet/
if [[ "$1" == '--test' ]]; then # Only for CI usage, user should not use --test flag.
if ! git diff --quiet &>/dev/null; then
echo '*** You have not formatted your code! Please run [bash format.sh] at root directory before commit! Thanks! ***'
exit 1
else
echo "Code style test passed!"
fi
fi