Skip to content

Commit bdef22d

Browse files
fix(hooks): remove deprecated husky shim and add package-manager fallback
1 parent a436af1 commit bdef22d

3 files changed

Lines changed: 30 additions & 3 deletions

File tree

.husky/pre-commit

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
#!/usr/bin/env sh
2-
. "$(dirname -- "$0")/_/husky.sh"
32

4-
yarn lint-staged
3+
set -e
4+
5+
if command -v yarn >/dev/null 2>&1; then
6+
yarn lint-staged
7+
elif command -v pnpm >/dev/null 2>&1; then
8+
pnpm lint-staged
9+
elif command -v npm >/dev/null 2>&1; then
10+
npx --no-install lint-staged
11+
else
12+
echo "[husky] No package manager found (yarn/pnpm/npm)."
13+
exit 127
14+
fi

.lintstagedrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
"*.{json,md,yml,yaml}": ["prettier --write"],
1111
"src/**/*.{ts,tsx}": ["tsc --noEmit"],
1212
"tests/**/*.{ts,tsx}": ["tsc --noEmit"],
13-
"package.json": ["yarn audit --level moderate"]
13+
"package.json": ["sh ./scripts/run-security-audit.sh"]
1414
}

scripts/run-security-audit.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
5+
# Prefer yarn when yarn.lock is present; fall back to npm only when package-lock exists.
6+
if command -v yarn >/dev/null 2>&1; then
7+
yarn audit --level moderate
8+
exit $?
9+
fi
10+
11+
if command -v npm >/dev/null 2>&1 && [ -f package-lock.json ]; then
12+
npm audit --audit-level=moderate
13+
exit $?
14+
fi
15+
16+
echo "[audit] Skipping dependency audit: yarn not installed and no npm lockfile found."
17+
exit 0

0 commit comments

Comments
 (0)