diff --git a/.husky/pre-commit b/.husky/pre-commit index 0f04b859c..ea48d6b17 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -2,4 +2,9 @@ . "$(dirname -- "$0")/_/husky.sh" yarn lint-staged -cargo fmt --all --check --manifest-path rust/Cargo.toml + +# if any *.rs files have changed +if git diff --staged --exit-code --name-only | grep -q -E ".*\.rs$"; then + echo "Running cargo fmt pre-commit hook" + cargo fmt --all --check --manifest-path rust/Cargo.toml +fi