mirror of
https://github.com/andatoshiki/toshiki-notebook.git
synced 2026-06-06 09:16:45 +00:00
feat: add new husky git hooks and remove some unused scripts
This commit is contained in:
parent
c0fce87faa
commit
92ae2f30b7
@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
. "$(dirname -- "$0")/_/husky.sh"
|
. "$(dirname -- "$0")/_/husky.sh"
|
||||||
|
|
||||||
npx --no -- commitlint --edit ${1}
|
node scripts/verifyCommit.js
|
||||||
|
|||||||
5
.husky/pre-commit
Normal file → Executable file
5
.husky/pre-commit
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
yarn lint
|
npx lint-staged
|
||||||
@ -1,33 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
read -p "Enter the directory where you want to generate the files (leave blank to generate in current directory): " dir
|
|
||||||
|
|
||||||
if [ -z "$dir" ]; then
|
|
||||||
dir="."
|
|
||||||
fi
|
|
||||||
|
|
||||||
read -p "Enter the unit number: " unit
|
|
||||||
read -p "Enter the starting chapter number: " start_chapter
|
|
||||||
read -p "Enter the number of chapters to generate: " num_chapters
|
|
||||||
read -p "Do you want to generate files in descending order? (y/n): " descending
|
|
||||||
|
|
||||||
if [ "$num_chapters" = "0" ]; then
|
|
||||||
filename="$unit.md"
|
|
||||||
touch "$dir/$filename"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "" = "" ]
|
|
||||||
|
|
||||||
if [ "$start_chapter" = "0" ]; then
|
|
||||||
filename="$unit-$chapter"
|
|
||||||
|
|
||||||
if
|
|
||||||
for (( i=$start_chapter; i<=$start_chapter+$num_chapters-1; i++ ))
|
|
||||||
do
|
|
||||||
filename="$unit-$i.md"
|
|
||||||
touch "$dir/$filename"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Files generated successfully in $dir."
|
|
||||||
17
scripts/verifyCommit.js
Normal file
17
scripts/verifyCommit.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const msg = require('fs')
|
||||||
|
.readFileSync('.git/COMMIT_EDITMSG', 'utf-8')
|
||||||
|
.trim()
|
||||||
|
|
||||||
|
const commitRE = /^(revert: )?(feat|fix|docs|dx|style|refactor|perf|test|workflow|build|ci|chore|types|wip|release)(\(.+\))?: .{1,50}/
|
||||||
|
const mergeRe = /^(Merge pull request|Merge branch)/
|
||||||
|
if (!commitRE.test(msg)) {
|
||||||
|
if(!mergeRe.test(msg)){
|
||||||
|
console.log('git commit message does not pass validation')
|
||||||
|
|
||||||
|
console.error(`git commit message format error, use \" title(scope): desc\" as the format`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
console.log('git commit message validation test passes')
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user