-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathpre-push
More file actions
executable file
·50 lines (41 loc) · 1.23 KB
/
pre-push
File metadata and controls
executable file
·50 lines (41 loc) · 1.23 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env sh
set -eu
echo "[pre-push] 린트 검사 시작"
npm run lint
echo "[pre-push] 마크다운 포맷 검사 시작"
CHANGED_MARKDOWN_FILES=""
while read -r local_ref local_sha remote_ref remote_sha; do
if [ -z "$local_ref" ]; then
continue
fi
if [ "$remote_sha" = "0000000000000000000000000000000000000000" ]; then
range="${local_sha}^!"
elif ! git rev-parse --verify "${remote_sha}^{commit}" >/dev/null 2>&1; then
range="${local_sha}^!"
else
range="$remote_sha..$local_sha"
fi
files="$(git diff --name-only --diff-filter=ACMRT "$range" -- '*.md' || true)"
if [ -n "$files" ]; then
CHANGED_MARKDOWN_FILES="${CHANGED_MARKDOWN_FILES}
${files}"
fi
done
MARKDOWN_FILES="$(printf '%s\n' "$CHANGED_MARKDOWN_FILES" | sed '/^$/d' | sort -u)"
if [ -n "$MARKDOWN_FILES" ]; then
CHECK_TARGETS=""
for file in $MARKDOWN_FILES; do
if [ -L "$file" ]; then
continue
fi
CHECK_TARGETS="${CHECK_TARGETS}
${file}"
done
CHECK_TARGETS="$(printf '%s\n' "$CHECK_TARGETS" | sed '/^$/d')"
if [ -n "$CHECK_TARGETS" ]; then
echo "$CHECK_TARGETS" | xargs npx prettier --check
fi
fi
echo "[pre-push] 코드 커버리지 검사 시작"
npm run test:coverage
echo "[pre-push] 모든 검사 통과"