Skip to content

Commit aebce10

Browse files
committed
squash
1 parent 4e99b69 commit aebce10

2 files changed

Lines changed: 47 additions & 0 deletions

File tree

bin/git/hooks/pre-commit

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
3+
spinner() {
4+
# PID of the background Pint process
5+
pid="$1"
6+
# How long the spinner should wait between frames
7+
delay=0.1
8+
# Characters for spinner animation
9+
spin='-\|/'
10+
# Wait while the process is processing
11+
while kill -0 "$pid" 2>/dev/null; do
12+
# Spinner animation
13+
c=$(printf "%s" "$spin" | cut -c1) # take first character
14+
printf "\r%s Running Pint..." "$c"
15+
# Spinner animation
16+
spin=$(printf "%s" "$spin" | cut -c2-)"$(printf "%s" "$spin" | cut -c1)"
17+
18+
sleep "$delay"
19+
done
20+
21+
printf "\rDone. \n"
22+
}
23+
# TODO do I check only for updated files?
24+
# if not do this.
25+
echo "Checking PHP code style…"
26+
27+
# Run Pint in background
28+
vendor/bin/pint --quiet &
29+
# $! is the PID of the most recent background process.
30+
spinner $!
31+
# Statis of spinner which is the status of pint
32+
STATUS=$?
33+
34+
if [ $STATUS -eq 0 ]; then
35+
36+
printf "\r✔ Pint completed successfully!\n"
37+
38+
echo "Adding linted changes to Git…"
39+
git add -u # Stages updated files only
40+
41+
printf "✔ Changes have been staged.\n"
42+
else
43+
printf "\r✖ Pint found issues. Fixing needed.\n"
44+
exit 1
45+
fi

bin/install-git-hooks.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
cp -r bin/git/hooks/ .git/

0 commit comments

Comments
 (0)