-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathlint-markdown
More file actions
executable file
·24 lines (18 loc) · 1.09 KB
/
lint-markdown
File metadata and controls
executable file
·24 lines (18 loc) · 1.09 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
#!/bin/bash
set -euo pipefail
# To make things simpler, ensure we're in the repo's root directory (one directory up) before
# running, regardless where the user is when invoking this script.
# Grab the full directory name for where this script lives.
script_dir=$(readlink -f "$0" | xargs dirname)
# Move up to the root since we want to do everything relative to that. Note that this only impacts
# this script, but will leave the user wherever they were when the script exists.
cd "${script_dir}/.." >/dev/null || exit 1
link_check_config=".github/workflows/markdownlint-config.json"
if command -v markdown-link-check > /dev/null; then
link_check_cmd=markdown-link-check
else
link_check_cmd="npx markdown-link-check"
fi
# Recursively find all markdown files (*.md) in the current directory, excluding node_modules and .venv subfolders.
# Pass them in as args to the lint command using the handy `xargs` command.
find . -name \*.md -not -path "*/node_modules/*" -not -path "*/.venv/*" -not -path "*/.terraform/*" -print0 | xargs -0 -I{} sh -c "${link_check_cmd} --quiet --config ${link_check_config} {}"