summaryrefslogtreecommitdiff
path: root/.scripts.d/10-check.sh
blob: 422b8c831f2f147a5e67f09bcfe75fa2d161497a (plain) (blame)
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
#!/bin/bash
# vim: ai:ts=8:sw=8:noet
set -EeufCo pipefail
export SHELLOPTS # propagate set to children by default
IFS=$'\t\n'

# check required commands are in place
command -v docker >/dev/null 2>&1 || {
	echo 'please install docker-client'
	exit 1
}

command -v find >/dev/null 2>&1 || {
	echo 'please install GNU find'
	exit 1
}

if [[ ! "$(find --version)" =~ GNU ]]; then
	echo 'please install GNU find'
	exit 1
fi

docker run --rm \
	-v "$(pwd)":/site \
	-w /site \
	nixos/nix:2.21.4 \
	bash -c '\
	nix develop --extra-experimental-features "nix-command flakes" \
	-c bash -c "prettier --prose-wrap=always -c content/**/*.md"
	'

echo "Ensure all posts are named with the date prefix" >&2
find content/posts -type f -name "*.md" | while read -r f; do
	if [[ ! "$f" =~ ^content/posts/[0-9]{4}-[0-9]{2}-[0-9]{2}-.*\.md$ ]]; then
		echo "Filename $f does not match date pattern"
		exit 1
	fi
done