diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100755 index 000000000..8e7ed0c56 --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,11 @@ +#!/bin/sh +FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g') +[ -z "$FILES" ] && exit 0 + +# Prettify all selected files +echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write + +# Add back the modified/prettified files to staging +echo "$FILES" | xargs git add + +exit 0 \ No newline at end of file diff --git a/package.json b/package.json index a12981766..818632aa8 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@types/jest": "^28.1.3", "ethers": "^5.6.9", "hardhat": "^2.9.9", + "husky": "^8.0.1", "jest": "^28.1.1", "prettier": "^2.7.1", "prettier-plugin-solidity": "^1.0.0-beta.19", diff --git a/yarn.lock b/yarn.lock index edff60506..f4179defb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3094,6 +3094,11 @@ human-signals@^2.1.0: resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== +husky@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/husky/-/husky-8.0.1.tgz#511cb3e57de3e3190514ae49ed50f6bc3f50b3e9" + integrity sha512-xs7/chUH/CKdOCs7Zy0Aev9e/dKOMZf3K1Az1nar3tzlv0jfqnYtu235bstsWTmXOR0EfINrPa97yy4Lz6RiKw== + iconv-lite@0.4.24, iconv-lite@^0.4.24: version "0.4.24" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.24.tgz#2022b4b25fbddc21d2f524974a474aafe733908b"