diff options
author | Rich Trott <rtrott@gmail.com> | 2020-02-23 14:25:09 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-03-01 21:39:48 +0300 |
commit | 751c2409db0242dffec7fc1e49b1ec02110a1320 (patch) | |
tree | d720228c189329b2d8dbb565826bbaa15d82b50f /Makefile | |
parent | 1e8625c622d4f3463fa0138e9912615b162ec296 (diff) |
build: only lint markdown files that have changed (POSIX-only)
Update Makefile so that only markdown files that have changed will be
linted. Currently, if one file in doc/api has changed, all files in
doc/api are linted.
On Windows, the lint-md task currently lints all files regardless of
whether any files has changed, and that behavior is unchanged here.
A further improvement is that when tools/lint-md.js is rebuilt, the
timestamp file is removed so that all files are linted again. This is
because rebuilding lint-md.js can introduce new rules or modify existing
rules, so re-linting everything helps make sure that accidental breakage
doesn't slip by unnoticed.
PR-URL: https://github.com/nodejs/node/pull/31923
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 34 |
1 files changed, 15 insertions, 19 deletions
@@ -1165,6 +1165,7 @@ bench-addons-clean: .PHONY: lint-md-rollup lint-md-rollup: + $(RM) tools/.*mdlintstamp cd tools/node-lint-md-cli-rollup && npm install cd tools/node-lint-md-cli-rollup && npm run build-node @@ -1177,28 +1178,23 @@ lint-md-clean: lint-md-build: $(warning "Deprecated no-op target 'lint-md-build'") -LINT_MD_DOC_FILES = $(shell find doc -type f -name '*.md') -run-lint-doc-md = tools/lint-md.js -q -f $(LINT_MD_DOC_FILES) -# Lint all changed markdown files under doc/ -tools/.docmdlintstamp: $(LINT_MD_DOC_FILES) - @echo "Running Markdown linter on docs..." - @$(call available-node,$(run-lint-doc-md)) - @touch $@ +ifeq ("$(wildcard tools/.mdlintstamp)","") + LINT_MD_NEWER = +else + LINT_MD_NEWER = -newer tools/.mdlintstamp +endif -LINT_MD_TARGETS = src lib benchmark test tools/doc tools/icu -LINT_MD_ROOT_DOCS := $(wildcard *.md) -LINT_MD_MISC_FILES := $(shell find $(LINT_MD_TARGETS) -type f \ - ! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md') \ - $(LINT_MD_ROOT_DOCS) -run-lint-misc-md = tools/lint-md.js -q -f $(LINT_MD_MISC_FILES) -# Lint other changed markdown files maintained by us -tools/.miscmdlintstamp: $(LINT_MD_MISC_FILES) - @echo "Running Markdown linter on misc docs..." - @$(call available-node,$(run-lint-misc-md)) +LINT_MD_TARGETS = doc src lib benchmark test tools/doc tools/icu $(wildcard *.md) +LINT_MD_FILES = $(shell find $(LINT_MD_TARGETS) -type f \ + ! -path '*node_modules*' ! -path 'test/fixtures/*' -name '*.md' \ + $(LINT_MD_NEWER)) +run-lint-md = tools/lint-md.js -q -f --no-stdout $(LINT_MD_FILES) +# Lint all changed markdown files maintained by us +tools/.mdlintstamp: $(LINT_MD_FILES) + @echo "Running Markdown linter..." + @$(call available-node,$(run-lint-md)) @touch $@ -tools/.mdlintstamp: tools/.miscmdlintstamp tools/.docmdlintstamp - .PHONY: lint-md # Lints the markdown documents maintained by us in the codebase. lint-md: | tools/.mdlintstamp |