Skip to content

Commit

Permalink
feat(githooks): add pre-commit and pre-push hooks
Browse files Browse the repository at this point in the history
This commit introduces two new git hooks: pre-commit and pre-push.
The pre-commit hook runs secretlint on staged files, while the pre-push
hook runs lint and check scripts. Additionally, a new "prepare" script
has been added to package.json to set the local git hooks path.
  • Loading branch information
ryoppippi committed May 30, 2024
1 parent 973f1f4 commit 84b6120
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env sh

# get the list of staged files
files=$(git diff --cached --name-only --diff-filter=ACM --relative="")

pnpm dlx @secretlint/quick-start $files
4 changes: 4 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh

pnpm lint
pnpm check
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
"lint": "eslint .",
"format": "eslint --fix ."
"format": "eslint --fix .",
"prepare": "git config --local core.hooksPath .githooks || echo 'Can not set git hooks'"
},
"dependencies": {
"@unocss/reset": "^0.60.3"
Expand Down

0 comments on commit 84b6120

Please sign in to comment.