Skip to content

Commit 84a286c

Browse files
committed
chore: make formatting run on staged files
1 parent 160a25a commit 84a286c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.husky/pre-commit

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1-
#!/usr/bin/env sh
1+
#!/bin/sh
2+
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
3+
[ -z "$FILES" ] && exit 0
24

3-
npm run format
5+
# Prettify all selected files
6+
echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
7+
8+
# Add back the modified/prettified files to staging
9+
echo "$FILES" | xargs git add
10+
11+
exit 0

0 commit comments

Comments
 (0)