forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-internal-links
executable file
·36 lines (30 loc) · 1.01 KB
/
check-internal-links
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
#!/usr/bin/env bash
# [start-readme]
# This script wraps tests/links-and-images.js and provides an option to output results to a file.
#
# For more information, see `tests/README.md#broken-link-test`.
# [end-readme]
# check if npx is installed
command -v npx >/dev/null 2>&1 || { echo -e "npx is not installed. Run:\n\n\$ npm install -g npx" >&2; exit 1; }
while getopts "h?f:" opt; do
case "${opt}" in
h|\?) echo "Usage:"
echo " script/check-internal-links [OPTIONS]"
echo ""
echo " script/check-internal-links -f [FILENAME] Output the results of tests/links-and-images to a file."
echo " script/check-internal-links -h Display this help message."
exit 0
;;
f) FILENAME="${OPTARG}"
;;
esac
done
shift $((OPTIND -1))
if [ "${FILENAME}" = "" ]
then
npx jest links-and-images
else
echo -e "Running tests/links-and-images.js\n"
npx jest links-and-images --no-color > ${FILENAME} 2>&1
echo "Done! Results in ${FILENAME}."
fi