Skip to content

Commit 2710616

Browse files
krydostniessen
authored andcommitted
build: remove duplicated code
Makefile contains copy-pasted code in some targets and this commit aims to remove it. PR-URL: #13482 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Kunal Pathak <[email protected]>
1 parent 949aec5 commit 2710616

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

Makefile

+15-16
Original file line numberDiff line numberDiff line change
@@ -492,28 +492,25 @@ out/doc/%: doc/%
492492

493493
# check if ./node is actually set, else use user pre-installed binary
494494
gen-json = tools/doc/generate.js --format=json $< > $@
495-
out/doc/api/%.json: doc/api/%.md
496-
@[ -e tools/doc/node_modules/js-yaml/package.json ] || \
495+
gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \
496+
--template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@
497+
498+
gen-doc = \
499+
[ -e tools/doc/node_modules/js-yaml/package.json ] || \
497500
[ -e tools/eslint/node_modules/js-yaml/package.json ] || \
498501
if [ -x $(NODE) ]; then \
499502
cd tools/doc && ../../$(NODE) ../../$(NPM) install; \
500503
else \
501504
cd tools/doc && node ../../$(NPM) install; \
502-
fi
503-
[ -x $(NODE) ] && $(NODE) $(gen-json) || node $(gen-json)
505+
fi;\
506+
[ -x $(NODE) ] && $(NODE) $(gen-json) || node
507+
508+
out/doc/api/%.json: doc/api/%.md
509+
$(gen-doc) $(gen-json)
504510

505511
# check if ./node is actually set, else use user pre-installed binary
506-
gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \
507-
--template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@
508512
out/doc/api/%.html: doc/api/%.md
509-
@[ -e tools/doc/node_modules/js-yaml/package.json ] || \
510-
[ -e tools/eslint/node_modules/js-yaml/package.json ] || \
511-
if [ -x $(NODE) ]; then \
512-
cd tools/doc && ../../$(NODE) ../../$(NPM) install; \
513-
else \
514-
cd tools/doc && node ../../$(NPM) install; \
515-
fi
516-
[ -x $(NODE) ] && $(NODE) $(gen-html) || node $(gen-html)
513+
$(gen-doc) $(gen-html)
517514

518515
docopen: $(apidocs_html)
519516
@$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html
@@ -880,15 +877,17 @@ bench: bench-net bench-http bench-fs bench-tls
880877

881878
bench-ci: bench
882879

880+
JSLINT_TARGETS = benchmark doc lib test tools
881+
883882
jslint:
884883
@echo "Running JS linter..."
885884
$(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules --ext=.js,.md \
886-
benchmark doc lib test tools
885+
$(JSLINT_TARGETS)
887886

888887
jslint-ci:
889888
@echo "Running JS linter..."
890889
$(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
891-
benchmark doc lib test tools
890+
$(JSLINT_TARGETS)
892891

893892
CPPLINT_EXCLUDE ?=
894893
CPPLINT_EXCLUDE += src/node_root_certs.h

0 commit comments

Comments
 (0)