-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathMakefile
More file actions
33 lines (31 loc) · 1.11 KB
/
Makefile
File metadata and controls
33 lines (31 loc) · 1.11 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
25
26
27
28
29
30
31
32
33
SHELL=bash
.PHONY: lint_docs
LINT_DOCS ?= "docs/"
WATCH_DOCS ?= "false"
fn_vale = vale --config ".vale.ini" --no-global --glob "*.md" $(1)
lint_docs:
@vale sync
@EXIT_CODE=0; \
$(call fn_vale,${LINT_DOCS}); \
EXIT_CODE=$$?; \
if [ "${LINT_DOCS}" == "docs/" ]; then \
1>&2 echo ""; \
1>&2 echo "TIP: use the LINT_DOCS variable to target just the documents you want to lint"; \
1>&2 echo -e "\n\tmake lint_docs LINT_DOCS=./docs/README.md"; \
fi; \
if [ "${WATCH_DOCS}" == true ]; then \
if ! which fswatch >/dev/null; then \
echo "fswatch not found in the path."; \
echo "fswatch is required for watching for file changes"; \
exit 1; \
fi; \
fswatch -r -e ".*" -i "\\.md$$" -i "\\.txt$$" -i "\\.yml$$" .vale/ ${LINT_DOCS} \
| xargs -I {} sh -c 'clear && $(call fn_vale,{})'; \
exit; \
else \
1>&2 echo ""; \
1>&2 echo "TIP: use WATCH_DOCS=true to re-run the linter whenever the files change"; \
1>&2 echo -e "\n\tmake lint_docs WATCH_DOCS=true"; \
1>&2 echo -e "\tmake lint_docs LINT_DOCS=./docs/README.md WATCH_DOCS=true"; \
fi; \
exit $${EXIT_CODE};