Răsfoiți Sursa

fix: configure husky hooks for reliable execution

Enhance husky pre-commit and pre-push hooks to ensure consistent and reliable execution.

- Set executable bit on both pre-commit and pre-push scripts.
- Implement robust PATH resolution within hooks using git rev-parse to find the repository root.
- Add a safety check for 'node_modules/.bin' directory existence before modifying the PATH.
- Addresses issues with tools not being found and inconsistent execution environments.
Christian Couder 2 luni în urmă
părinte
comite
c7eee433da
2 a modificat fișierele cu 16 adăugiri și 0 ștergeri
  1. 8 0
      .husky/pre-commit
  2. 8 0
      .husky/pre-push

+ 8 - 0
.husky/pre-commit

@@ -1,3 +1,11 @@
+#!/usr/bin/env sh
+# Add node_modules/.bin to PATH for local binaries
+# Use git to find the repository root reliably
+REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$(dirname -- "$0")/../..")"
+if [ -d "$REPO_ROOT/node_modules/.bin" ]; then
+    export PATH="$REPO_ROOT/node_modules/.bin:$PATH"
+fi
+
 branch="$(git rev-parse --abbrev-ref HEAD)"
 
 if [ "$branch" = "main" ]; then

+ 8 - 0
.husky/pre-push

@@ -1,3 +1,11 @@
+#!/usr/bin/env sh
+# Add node_modules/.bin to PATH for local binaries
+# Use git to find the repository root reliably
+REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || echo "$(dirname -- "$0")/../..")"
+if [ -d "$REPO_ROOT/node_modules/.bin" ]; then
+    export PATH="$REPO_ROOT/node_modules/.bin:$PATH"
+fi
+
 branch="$(git rev-parse --abbrev-ref HEAD)"
 
 if [ "$branch" = "main" ]; then