Skip to content

Commit

Permalink
Add a pre-commit hook to run prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpojer committed Dec 1, 2023
1 parent 6e35da1 commit 9cd0f93
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions git-hooks/pre-commit
@@ -0,0 +1,7 @@
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
echo "$FILES" | xargs pnpm prettier --ignore-unknown --write
echo "$FILES" | xargs git add

exit 0
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -36,6 +36,7 @@
"vitest": "^0.34.6"
},
"scripts": {
"preinstall": "command -v git >/dev/null 2>&1 && git config core.hooksPath git-hooks || true",
"build": "vite build",
"dev:update-deps": "rm -rf pnpm-lock.yaml node_modules/ **/node_modules && pnpm install",
"dev": "vite dev",
Expand Down

0 comments on commit 9cd0f93

Please sign in to comment.