Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ forge test
```sh
forge snapshot
```

### Pre-commit Hook

We recommend installing the accompanying pre-commit hook to automatically run `forge fmt` and `forge snapshot` on each commit:

```bash
cp hooks/pre-commit .git/hooks/pre-commit
```
24 changes: 24 additions & 0 deletions hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

BWHITE='\033[1;37m'
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m'

printf "Running ${BWHITE}forge fmt${NC}... \n"
if forge fmt &>/dev/null; then
printf "${GREEN}Formatted!${NC} \n"
else
printf "${RED}error running ${BWHITE}forge fmt${NC} \n"
exit 1
fi

printf "Running ${BWHITE}forge snapshot${NC}... \n"
if forge snapshot &>/dev/null; then
printf "${GREEN}Snapshotted!${NC} \n"
else
printf "${RED}error running ${BWHITE}forge snapshot${NC} \n"
exit 1
fi

git add .