Files
Thibault Duplessis 54b11f7e32 let pre-commit lint-stage find the config on its own
as the explicit path doesn't seem to work the same on all platform,
either looking from $ROOT or from $ROOT/ui
2026-03-22 10:21:24 +01:00

23 lines
763 B
Bash
Executable File

#!/bin/sh
# Short circuit lint-staged to avoid waiting on node when not needed. Even
# when no files match, and we execute lint-stage directly, it still delays
# the commit by .15s or so, which is annoying.
if \git --no-pager diff-index -z --name-only --no-renames --cached HEAD |
\grep -qzE '\.(json|ts|mts|mjs|scss)$'; then
# NOTE! grep must be kept in sync with lint-staged config (ui/lint-staged-config.mjs)
ROOT_DIR="$(dirname -- $0)/../.."
NODE_BIN="$ROOT_DIR/node_modules/.bin/lint-staged"
SYS_BIN="$(which lint-staged 2>/dev/null)"
# pnpm or npx adds .25s overhead. exec further reduces overhead.
if [ -x "$NODE_BIN" ]; then
exec "$NODE_BIN"
elif [ -x "$SYS_BIN" ]; then
exec "$SYS_BIN"
else
exec pnpm lint-staged
fi
fi