+44
.husky/pre-commit
+44
.husky/pre-commit
···
···
1
+
#!/bin/sh
2
+
3
+
#
4
+
# clippr: a social bookmarking service for the AT Protocol
5
+
# Copyright (c) 2025 clippr contributors.
6
+
# SPDX-License-Identifier: AGPL-3.0-only
7
+
#
8
+
9
+
# Collect staged files
10
+
STAGED=$(git diff --cached --name-only)
11
+
12
+
# Track exit status
13
+
FAILED=0
14
+
15
+
echo "Testing code for any errors before committing..."
16
+
17
+
run_cmds() {
18
+
desc=$1
19
+
shift
20
+
echo "Running pre-commit checks for $desc..."
21
+
if ! "$@"; then
22
+
echo "ERROR: Pre-commit checks for $desc failed. Aborting commit."
23
+
FAILED=1
24
+
fi
25
+
}
26
+
27
+
echo "$STAGED" | grep -q "^backend/" && run_cmds "backend" pnpm run fmt && pnpm run lint
28
+
git update-index --again
29
+
30
+
echo "$STAGED" | grep -q "^frontend/" && run_cmds "frontend" pnpm run fmt
31
+
git update-index --again
32
+
33
+
echo "$STAGED" | grep -q "^lexicons/" && run_cmds "lexicons" pnpm run generate && pnpm run prepublish
34
+
git update-index --again
35
+
36
+
# If any failed, block commit
37
+
if [ $FAILED -ne 0 ]; then
38
+
echo "Commit aborted due to failed checks. Please fix your code before committing."
39
+
exit 1
40
+
fi
41
+
42
+
echo "All relevant checks passed. Proceeding with commit."
43
+
exit 0
44
+
+10
package.json
+10
package.json
+24
pnpm-lock.yaml
+24
pnpm-lock.yaml
···
···
1
+
lockfileVersion: '9.0'
2
+
3
+
settings:
4
+
autoInstallPeers: true
5
+
excludeLinksFromLockfile: false
6
+
7
+
importers:
8
+
9
+
.:
10
+
devDependencies:
11
+
husky:
12
+
specifier: ^9.1.7
13
+
version: 9.1.7
14
+
15
+
packages:
16
+
17
+
husky@9.1.7:
18
+
resolution: {integrity: sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==}
19
+
engines: {node: '>=18'}
20
+
hasBin: true
21
+
22
+
snapshots:
23
+
24
+
husky@9.1.7: {}