We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 09dafa8 commit 9daab7bCopy full SHA for 9daab7b
pre-commit.sh
@@ -17,6 +17,8 @@ BOLD='\033[1m'
17
# Git metadata
18
BRANCH_NAME=$(git branch | grep '.*' | sed 's/* //')
19
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
22
23
echo "* ${BOLD}Checking for unstashed changes:${NC}"
24
stash=0
@@ -44,8 +46,8 @@ echo "* ${BOLD}Testing and formatting:${NC}"
44
46
45
47
# If using mulitple commands, append && to all but the last so if any one fails
48
# it's accurately represented in the exit code.
-shellcheck -a ./*.sh &&
- prettier --write .
49
+echo "$FILES" | xargs prettier --ignore-unknown --write &&
50
+ echo "$FILES" | xargs git add
51
52
# Capture exit code from tests
53
status=$?
0 commit comments