#!/bin/bash echo "Checking your formatting..." HAS_ISSUES=0 for file in $(git diff --name-only --staged); do FMT_RESULT="$(rustfmt --edition 2021 --skip-children --force --write-mode diff $file 2>/dev/null || true)" if [ "$FMT_RESULT" != "" ]; then echo -n "$file (rustfmt)" HAS_ISSUES=1 fi done FIRST_FILE=1 cd starkingdoms-client for file in $(git diff --name-only --staged); do if [ $file == starkingdoms-client* ]; then FMT_RESULT="$(yarn prettier $file --check 2>&1 > /dev/null || true)" if [ "$FMT_RESULT" != "" ]; then if [ $FIRST_FILE -eq 0 ]; then echo "cd starkingdoms-client" fi echo -n "yarn prettier $file --write" HAS_ISSUES=1 FIRST_FILE=0 fi fi done if [ $HAS_ISSUES -eq 0 ]; then echo "Everything looks good! Proceeding with commit." exit 0 fi echo "!! Some files have formatting issues! Run all of the above commands, and then attempt another commit." exit 1