forked from microsoft/vscode-pull-request-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpre-commit
More file actions
executable file
·37 lines (31 loc) · 938 Bytes
/
Copy pathpre-commit
File metadata and controls
executable file
·37 lines (31 loc) · 938 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Hygiene reads staged contents while ESLint checks the working tree, so they can run concurrently.
node ./build/hygiene.js &
hygiene_pid=$!
lint_pid=''
# Lint only staged TS/TSX files instead of the whole repo (much faster).
# Stream a NUL-delimited list directly to xargs -0 so paths with spaces/newlines
# are handled safely (command substitution would strip NUL bytes).
if git diff --cached --name-only --diff-filter=ACMR -- '*.ts' '*.tsx' | grep -q .; then
git diff --cached --name-only --diff-filter=ACMR -z -- '*.ts' '*.tsx' | xargs -0 node ./node_modules/eslint/bin/eslint.js --fix --cache &
lint_pid=$!
fi
hygiene_status=0
if wait "$hygiene_pid"; then
:
else
hygiene_status=$?
fi
lint_status=0
if [ -n "$lint_pid" ]; then
if wait "$lint_pid"; then
:
else
lint_status=$?
fi
fi
if [ "$hygiene_status" -ne 0 ]; then
exit "$hygiene_status"
fi
exit "$lint_status"