Skip to content

Commit

Permalink
Switch to pre-commit hook
Browse files Browse the repository at this point in the history
Co-Authored-By: Daniel Coulbourne <[email protected]>
  • Loading branch information
inxilpro and DanielCoulbourne committed Dec 29, 2023
1 parent ec0892f commit 49983f3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
24 changes: 24 additions & 0 deletions bin/pre-commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

# Move into project root
BIN_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$BIN_DIR"
cd ..

# Exit on errors
set -e

CHANGED_FILES=$(git diff --cached --name-only --diff-filter=ACM -- '***.php')

if [[ -z "$CHANGED_FILES" ]]; then
echo 'No changed files'
exit 0
fi

if [[ -x vendor/bin/pint ]]; then
vendor/bin/pint --dirty
git add $CHANGED_FILES
else
echo 'pint is not installed'
exit 1
fi
2 changes: 1 addition & 1 deletion whisky.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"disabled": [],
"hooks": {
"pre-commit": [
"composer format"
"./bin/pre-commit.sh"
]
}
}

0 comments on commit 49983f3

Please sign in to comment.