Skip to content

Commit e60032e

Browse files
committed
lefthookへ乗り換え
1 parent 63d711e commit e60032e

File tree

7 files changed

+233
-310
lines changed

7 files changed

+233
-310
lines changed

.husky/_/pre-commit

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook -h >/dev/null 2>&1
17+
then
18+
lefthook "$@"
19+
else
20+
dir="$(git rev-parse --show-toplevel)"
21+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
22+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
23+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
24+
then
25+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
26+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
27+
then
28+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
32+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
33+
then
34+
"$dir/node_modules/lefthook/bin/index.js" "$@"
35+
36+
elif bundle exec lefthook -h >/dev/null 2>&1
37+
then
38+
bundle exec lefthook "$@"
39+
elif yarn lefthook -h >/dev/null 2>&1
40+
then
41+
yarn lefthook "$@"
42+
elif pnpm lefthook -h >/dev/null 2>&1
43+
then
44+
pnpm lefthook "$@"
45+
elif swift package plugin lefthook >/dev/null 2>&1
46+
then
47+
swift package --disable-sandbox plugin lefthook "$@"
48+
elif command -v mint >/dev/null 2>&1
49+
then
50+
mint run csjones/lefthook-plugin "$@"
51+
else
52+
echo "Can't find lefthook in PATH"
53+
echo "ERROR: Operation is aborted due to lefthook settings."
54+
echo "Make sure lefthook is available in your environment and re-try."
55+
echo "To skip these checks use --no-verify git argument or set LEFTHOOK=0 env variable."
56+
exit 1
57+
fi
58+
fi
59+
}
60+
61+
call_lefthook run "pre-commit" "$@"

.husky/_/prepare-commit-msg

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
3+
if [ "$LEFTHOOK_VERBOSE" = "1" -o "$LEFTHOOK_VERBOSE" = "true" ]; then
4+
set -x
5+
fi
6+
7+
if [ "$LEFTHOOK" = "0" ]; then
8+
exit 0
9+
fi
10+
11+
call_lefthook()
12+
{
13+
if test -n "$LEFTHOOK_BIN"
14+
then
15+
"$LEFTHOOK_BIN" "$@"
16+
elif lefthook -h >/dev/null 2>&1
17+
then
18+
lefthook "$@"
19+
else
20+
dir="$(git rev-parse --show-toplevel)"
21+
osArch=$(uname | tr '[:upper:]' '[:lower:]')
22+
cpuArch=$(uname -m | sed 's/aarch64/arm64/;s/x86_64/x64/')
23+
if test -f "$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook"
24+
then
25+
"$dir/node_modules/lefthook-${osArch}-${cpuArch}/bin/lefthook" "$@"
26+
elif test -f "$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook"
27+
then
28+
"$dir/node_modules/@evilmartians/lefthook/bin/lefthook-${osArch}-${cpuArch}/lefthook" "$@"
29+
elif test -f "$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook"
30+
then
31+
"$dir/node_modules/@evilmartians/lefthook-installer/bin/lefthook" "$@"
32+
elif test -f "$dir/node_modules/lefthook/bin/index.js"
33+
then
34+
"$dir/node_modules/lefthook/bin/index.js" "$@"
35+
36+
elif bundle exec lefthook -h >/dev/null 2>&1
37+
then
38+
bundle exec lefthook "$@"
39+
elif yarn lefthook -h >/dev/null 2>&1
40+
then
41+
yarn lefthook "$@"
42+
elif pnpm lefthook -h >/dev/null 2>&1
43+
then
44+
pnpm lefthook "$@"
45+
elif swift package plugin lefthook >/dev/null 2>&1
46+
then
47+
swift package --disable-sandbox plugin lefthook "$@"
48+
elif command -v mint >/dev/null 2>&1
49+
then
50+
mint run csjones/lefthook-plugin "$@"
51+
else
52+
echo "Can't find lefthook in PATH"
53+
echo "ERROR: Operation is aborted due to lefthook settings."
54+
echo "Make sure lefthook is available in your environment and re-try."
55+
echo "To skip these checks use --no-verify git argument or set LEFTHOOK=0 env variable."
56+
exit 1
57+
fi
58+
fi
59+
}
60+
61+
call_lefthook run "prepare-commit-msg" "$@"

.husky/pre-commit

Lines changed: 0 additions & 1 deletion
This file was deleted.

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
strict-peer-dependencies=false
22
provenance=true
3+
side-effects-cache=false

lefthook.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
assert_lefthook_installed: true
2+
3+
pre-commit:
4+
parallel: true
5+
jobs:
6+
- name: Sort package.json
7+
run: pnpm run sort:package
8+
glob: '{package.json,**/package.json}'
9+
stage_fixed: true

package.json

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,21 @@
1313
},
1414
"license": "MIT",
1515
"scripts": {
16-
"build": "turbo run build",
16+
"build": "turbo run build --parallel",
1717
"build:watch": "turbo run build:watch",
1818
"clean": "turbo run clean",
1919
"lint:code": "turbo lint:code --parallel",
2020
"lint:type": "turbo lint:type --parallel",
21-
"prepare": "husky",
2221
"sort:package": "sort-package-json 'package.json' 'packages/*/package.json'",
2322
"version": "changeset",
2423
"version:apply": "changeset version",
2524
"version:publish": "changeset publish"
2625
},
27-
"lint-staged": {
28-
"{package.json,**/package.json}": [
29-
"bash -c 'pnpm run sort:package'"
30-
]
31-
},
3226
"devDependencies": {
3327
"@changesets/changelog-github": "^0.5.0",
3428
"@changesets/cli": "^2.27.11",
3529
"@huuyafwww/tsconfig-common": "^1.1.1",
36-
"husky": "^9.1.7",
37-
"lint-staged": "^15.4.1",
30+
"lefthook": "^1.10.10",
3831
"sort-package-json": "^2.14.0",
3932
"turbo": "^2.3.3",
4033
"typescript": "^5.7.3"

0 commit comments

Comments
 (0)