Skip to content

Commit 04a2e50

Browse files
committed
fix(docs): use version-aware strip-types flag in pre-commit example (#588)
Detect Node version at runtime and select --strip-types (>=23) vs --experimental-strip-types (22.x), matching the approach in vitest.config.ts.
1 parent a6b8f2e commit 04a2e50

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

docs/examples/claude-code-hooks/pre-commit.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ fi
4848

4949
# Run all checks in a single Node.js process
5050
HOOK_DIR="$(cd "$(dirname "$0")" && pwd)"
51-
RESULT=$(node --experimental-strip-types "$HOOK_DIR/pre-commit-checks.ts" "$WORK_ROOT" "$EDITED_FILES" "$STAGED" 2>/dev/null) || true
51+
STRIP_FLAG=$(node -e "const [M,m]=process.versions.node.split('.').map(Number); console.log(M>=23?'--strip-types':'--experimental-strip-types')")
52+
RESULT=$(node $STRIP_FLAG "$HOOK_DIR/pre-commit-checks.ts" "$WORK_ROOT" "$EDITED_FILES" "$STAGED" 2>/dev/null) || true
5253

5354
if [ -z "$RESULT" ]; then
5455
exit 0

0 commit comments

Comments
 (0)