Skip to content

Commit a2c5b33

Browse files
committed
Add precommit hook for running markdown-link-check
1 parent f6d9d62 commit a2c5b33

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.pre-commit-hooks.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,11 @@
7474
entry: hooks/helmlint.sh
7575
language: script
7676
files: \.((ya?ml)|(tpl))$
77+
78+
- id: markdown-link-check
79+
name: markdown-link-check
80+
description: Run markdown-link-check to check all the relative and absolute links in markdown docs.
81+
entry: hooks/mdlink-check.sh
82+
language: script
83+
files: \.md$
84+
exclude: vendor\/.*$

hooks/mdlink-check.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# OSX GUI apps do not pick up environment variables the same way as Terminal apps and there are no easy solutions,
6+
# especially as Apple changes the GUI app behavior every release (see https://stackoverflow.com/q/135688/483528). As a
7+
# workaround to allow GitHub Desktop to work, add this (hopefully harmless) setting here.
8+
export PATH=$PATH:/usr/local/bin
9+
10+
TMP_CONFIG="$(mktemp)"
11+
cat > "$TMP_CONFIG" <<EOF
12+
{
13+
"replacementPatterns": [
14+
{
15+
"pattern": "^/",
16+
"replacement": "file://$(pwd)"
17+
}
18+
]
19+
}
20+
EOF
21+
22+
markdown-link-check -c "$TMP_CONFIG"

0 commit comments

Comments
 (0)