Skip to content

Commit e2719d3

Browse files
committed
Make it easier to run validate-links, and not the rest
1 parent 45bf82c commit e2719d3

File tree

1 file changed

+41
-23
lines changed

1 file changed

+41
-23
lines changed

lint

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,59 @@
22

33
set -eu
44

5-
if [ "${1:-}" == "--fix" ] ; then
6-
npm exec -- markdownlint --ignore 'node_modules/' --fix '**/*.md'
7-
npm exec -- prettier --write .
8-
else
9-
trap '
10-
if [ $? -ne 0 ] ; then
11-
echo "Try '\''./lint --fix'\'' to see if any automatic fixes are possible"
5+
validate-links() {
6+
echo "validate-links: RUN"
7+
if npm exec -- node dist/validateLinks.js ; then
8+
echo validate-links: PASS
9+
else
10+
echo validate-links: FAIL
11+
return 1
1212
fi
13-
' 0
14-
15-
rc=0
13+
}
1614

17-
echo "validateLinks: ..."
18-
if npm exec -- node dist/validateLinks.js ; then
19-
echo validateLinks: PASS
20-
else
21-
echo validateLinks: FAIL
22-
rc=1
23-
fi
24-
25-
echo "markdownlint: ..."
15+
markdownlint() {
16+
echo "markdownlint: RUN"
2617
if npm exec -- markdownlint --ignore 'node_modules/' '**/*.md' ; then
2718
echo "markdownlint: PASS"
2819
else
2920
echo "markdownlint: FAIL"
30-
rc=1
21+
return 1
3122
fi
23+
}
3224

33-
echo "prettier: ..."
25+
prettier() {
26+
echo "prettier: RUN"
3427
if npm exec -- prettier --check . ; then
3528
echo "prettier: PASS"
3629
else
3730
echo "prettier: FAIL"
38-
rc=1
31+
return 1
3932
fi
33+
}
34+
35+
all() {
36+
local rc=0
37+
echo "lint: RUN"
38+
validate-links || rc=1
39+
markdownlint || rc=1
40+
prettier || rc=1
4041

41-
exit $rc
42+
if [ $rc -eq 0 ] ; then
43+
echo "lint: PASS"
44+
else
45+
echo "lint: FAIL"
46+
echo "Try '\''./lint --fix'\'' to see if any automatic fixes are possible"
47+
fi
48+
49+
return $rc
50+
}
51+
52+
if [ "${1:-}" == "--fix" ] ; then
53+
npm exec -- markdownlint --ignore 'node_modules/' --fix '**/*.md'
54+
npm exec -- prettier --write .
55+
elif
56+
[ "${1:-}" == "validate-links" ] ; then
57+
validate-links
58+
else
59+
all
4260
fi

0 commit comments

Comments
 (0)