File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # Copyright (c) Meta Platforms, Inc. and affiliates.
3
+ # All rights reserved.
4
+ #
5
+ # This source code is licensed under the BSD-style license found in the
6
+ # LICENSE file in the root directory of this source tree.
7
+
8
+ set -euo pipefail
9
+
10
+ status=0
11
+ green=' \e[1;32m' ; red=' \e[1;31m' ; cyan=' \e[1;36m' ; yellow=' \e[1;33m' ; reset=' \e[0m'
12
+ last_filepath=
13
+
14
+ while IFS=: read -r filepath link; do
15
+ if [ " $filepath " != " $last_filepath " ]; then
16
+ printf ' \n%s:\n' " $filepath "
17
+ last_filepath=$filepath
18
+ fi
19
+ if [ -e " $( dirname " $filepath " ) /${link%%#* } " ]; then
20
+ printf " ${green} OK${reset} ${cyan} %s${reset} \n" " $link "
21
+ else
22
+ printf " ${red} FAIL${reset} ${yellow} %s${reset} \n" " $link " >&2
23
+ status=1
24
+ fi
25
+ done < <(
26
+ git --no-pager grep --no-color -I -o -E \
27
+ ' \[[^]]+\]\([^)]*/[^)]*\)|href="[^"]*/[^"]*"' \
28
+ -- ' *' \
29
+ ' :(exclude).*' \
30
+ ' :(exclude)**/.*' \
31
+ ' :(exclude)**/*.lock' \
32
+ ' :(exclude)**/*.svg' \
33
+ ' :(exclude)**/*.xml' \
34
+ ' :(exclude)**/third-party/**' \
35
+ | grep -Ev ' https?://' \
36
+ | sed -E \
37
+ -e ' s#([^:]+):\[[^]]+\]\(([^)]+)\)#\1:\2#' \
38
+ -e ' s#([^:]+):href="([^"]+)"#\1:\2#' \
39
+ -e ' s/[[:punct:]]*$//' \
40
+ || true
41
+ )
42
+
43
+ exit $status
You can’t perform that action at this time.
0 commit comments