File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ cp -r bin/git/hooks/ .git/
You can’t perform that action at this time.
0 commit comments