mirror of
https://github.com/lichess-org/lila.git
synced 2026-05-26 13:51:00 +00:00
as the explicit path doesn't seem to work the same on all platform, either looking from $ROOT or from $ROOT/ui
23 lines
763 B
Bash
Executable File
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
|