Skip to content

Commit 9daab7b

Browse files
committed
Update precommit
Signed-off-by: Ivan Boothe <[email protected]>
1 parent 09dafa8 commit 9daab7b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Diff for: pre-commit.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ BOLD='\033[1m'
1717
# Git metadata
1818
BRANCH_NAME=$(git branch | grep '.*' | sed 's/* //')
1919
STASH_NAME="pre-commit-$(date +%s) on ${BRANCH_NAME}"
20+
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
21+
[ -z "$FILES" ] && exit 0
2022

2123
echo "* ${BOLD}Checking for unstashed changes:${NC}"
2224
stash=0
@@ -44,8 +46,8 @@ echo "* ${BOLD}Testing and formatting:${NC}"
4446

4547
# If using mulitple commands, append && to all but the last so if any one fails
4648
# it's accurately represented in the exit code.
47-
shellcheck -a ./*.sh &&
48-
prettier --write .
49+
echo "$FILES" | xargs prettier --ignore-unknown --write &&
50+
echo "$FILES" | xargs git add
4951

5052
# Capture exit code from tests
5153
status=$?

0 commit comments

Comments
 (0)