Skip to content

Commit

Permalink
chore: use simple-git-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 30, 2023
1 parent 341677b commit dbe0c3c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 130 deletions.
13 changes: 7 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"test:types": "tsc --build ./tsconfig.json",
"test:cov": "vitest run --coverage",
"build": "tsup",
"size": "size-limit"
"size": "size-limit",
"postinstall": "simple-git-hooks"
},
"files": [
"dist",
Expand Down Expand Up @@ -95,20 +96,20 @@
"lint-staged": "^15.2.0",
"pinia": "^2.1.7",
"prettier": "^3.1.1",
"simple-git-hooks": "^2.9.0",
"size-limit": "^11.0.1",
"standard-version": "^9.5.0",
"tsup": "^8.0.1",
"typescript": "~5.3.3",
"vitest": "^1.0.4",
"vue": "^3.3.11",
"yorkie": "^2.0.0"
"vue": "^3.3.11"
},
"gitHooks": {
"pre-commit": "lint-staged",
"simple-git-hooks": {
"pre-commit": "pnpm lint-staged",
"commit-msg": "node scripts/verifyCommit.js"
},
"lint-staged": {
"*.?(m)js": [
"*.{js,mjs,json,cjs}": [
"prettier --write"
],
"*.ts?(x)": [
Expand Down
131 changes: 9 additions & 122 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions scripts/verifyCommit.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
// @ts-check
import { readFileSync } from 'node:fs'
import path from 'node:path'

// Define raw escape codes for colors
const reset = '\x1b[0m'
const red = '\x1b[31m'
const green = '\x1b[32m'
const bgRedWhite = '\x1b[41m\x1b[37m'

const msgPath = process.env.GIT_PARAMS
const msgPath = path.resolve('.git/COMMIT_EDITMSG')
const msg = readFileSync(msgPath, 'utf-8').trim()

const commitRE =
Expand All @@ -17,7 +19,7 @@ if (!commitRE.test(msg)) {
console.error(
` ${bgRedWhite} ERROR ${reset} ${red}invalid commit message format.${reset}\n\n` +
`${red} Proper commit message format is required for automated changelog generation. Examples:\n\n` +
` ${green}fix(view): handle keep-alive with aborted navigations${reset}\n` +
` ${green}feat: add disableRoot option${reset}\n` +
` ${green}fix(view): handle keep-alive with aborted navigations (close #28)${reset}\n\n` +
`${red} See .github/commit-convention.md for more details.${reset}\n`
)
Expand Down

0 comments on commit dbe0c3c

Please sign in to comment.