-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
stub-check
executable file
·36 lines (31 loc) · 977 Bytes
/
stub-check
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
# handle colors and the unicode symbols '✓' and '✗'
readonly NORMAL="$(tput -Txterm sgr0)"
readonly RED_FAIL="$(tput -Txterm setaf 1)$(printf '\u2717')"
readonly GREEN_PASS="$(tput -Txterm setaf 2)$(printf '\u2713')"
# format the success messages
success () {
printf '%s\n' "${GREEN_PASS}${NORMAL} ${1}"
}
# convenience to pretend like this is perl
die () {
local err="${1:-something has gone horribly wrong}"
printf '%s\n' "${RED_FAIL}${NORMAL} ${err}"
exit 1
}
# make sure we are in the right place
if [[ ! -d exercises ]]; then
# can't run this script from wherever we are
die "can't run 'stub-check' from ${PWD}."
fi
pushd exercises/practice > /dev/null
for exercise in *; do
# verify the existence of the stub file
if [[ -f "${exercise}/${exercise}.el" ]]; then
success "${exercise}"
else
# no stub present
die "${exercise} is is missing its stub file."
fi
done
popd > /dev/null