mirror of https://github.com/jdx/mise
chore: husky -> lefthook (#227)
This commit is contained in:
parent
05f66907a3
commit
03db58baf0
|
@ -1,5 +1,42 @@
|
|||
#!/usr/bin/env sh
|
||||
set -e
|
||||
. "$(dirname -- "$0")/_/husky.sh"
|
||||
#!/bin/sh
|
||||
|
||||
just pre-commit
|
||||
if [ "$LEFTHOOK" = "0" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
call_lefthook()
|
||||
{
|
||||
dir="$(git rev-parse --show-toplevel)"
|
||||
osArch=$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')
|
||||
cpuArch=$(echo "$(uname -m)" | sed 's/aarch64/arm64/')
|
||||
|
||||
if lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
eval lefthook $@
|
||||
elif test -f "$dir/node_modules/lefthook/bin/index.js"
|
||||
then
|
||||
eval "\"$dir/node_modules/lefthook/bin/index.js\" $@"
|
||||
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
eval "\"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook\" $@"
|
||||
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
eval "\"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook\" $@"
|
||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
bundle exec lefthook $@
|
||||
elif yarn lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
yarn lefthook $@
|
||||
elif pnpm lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
pnpm lefthook $@
|
||||
elif npx @evilmartians/lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
npx @evilmartians/lefthook $@
|
||||
else
|
||||
echo "Can't find lefthook in PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
call_lefthook "run pre-commit $@"
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ "$LEFTHOOK" = "0" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
call_lefthook()
|
||||
{
|
||||
dir="$(git rev-parse --show-toplevel)"
|
||||
osArch=$(echo "$(uname)" | tr '[:upper:]' '[:lower:]')
|
||||
cpuArch=$(echo "$(uname -m)" | sed 's/aarch64/arm64/')
|
||||
|
||||
if lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
eval lefthook $@
|
||||
elif test -f "$dir/node_modules/lefthook/bin/index.js"
|
||||
then
|
||||
eval "\"$dir/node_modules/lefthook/bin/index.js\" $@"
|
||||
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
eval "\"$dir/node_modules/@evilmartians/lefthook/bin/lefthook_${osArch}_${cpuArch}/lefthook\" $@"
|
||||
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook"
|
||||
then
|
||||
eval "\"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook_${osArch}_${cpuArch}/lefthook\" $@"
|
||||
elif bundle exec lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
bundle exec lefthook $@
|
||||
elif yarn lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
yarn lefthook $@
|
||||
elif pnpm lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
pnpm lefthook $@
|
||||
elif npx @evilmartians/lefthook -h >/dev/null 2>&1
|
||||
then
|
||||
npx @evilmartians/lefthook $@
|
||||
else
|
||||
echo "Can't find lefthook in PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
call_lefthook "run prepare-commit-msg $@"
|
|
@ -9,6 +9,7 @@ for f in $FILES; do
|
|||
continue
|
||||
fi
|
||||
"$ROOT/e2e/run_test" "$f"
|
||||
echo
|
||||
done
|
||||
|
||||
echo "e2e: all tests passed"
|
||||
|
|
2
justfile
2
justfile
|
@ -89,7 +89,7 @@ render-mangen: build
|
|||
rtx mangen
|
||||
|
||||
# called by husky precommit hook
|
||||
pre-commit: lint render-help render-completions render-mangen
|
||||
pre-commit: render-help render-completions render-mangen
|
||||
git add README.md
|
||||
git add completions
|
||||
git add man
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
pre-commit:
|
||||
parallel: true
|
||||
commands:
|
||||
pre-commit:
|
||||
run: just pre-commit
|
||||
lint:
|
||||
run: just lint
|
10
package.json
10
package.json
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "@jdxcode/rtx",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"husky": "^8.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "husky install"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue