Skip to content

Commit 2a9afc4

Browse files
joyeecheungevanlucas
authored andcommitted
build: make lint-js independent of local node
PR-URL: #18272 Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent ce1eb0b commit 2a9afc4

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

Makefile

+10-20
Original file line numberDiff line numberDiff line change
@@ -1077,43 +1077,33 @@ lint-md:
10771077
endif
10781078

10791079
LINT_JS_TARGETS = benchmark doc lib test tools
1080-
LINT_JS_CMD = tools/node_modules/eslint/bin/eslint.js --cache \
1081-
--rulesdir=tools/eslint-rules --ext=.js,.mjs,.md \
1082-
$(LINT_JS_TARGETS)
1080+
1081+
run-lint-js = tools/node_modules/eslint/bin/eslint.js --cache \
1082+
--rulesdir=tools/eslint-rules --ext=.js,.mjs,.md $(LINT_JS_TARGETS)
1083+
run-lint-js-fix = $(run-lint-js) --fix
10831084

10841085
.PHONY: lint-js-fix
10851086
lint-js-fix:
1086-
@if [ -x $(NODE) ]; then \
1087-
$(NODE) $(LINT_JS_CMD) --fix; \
1088-
else \
1089-
node $(LINT_JS_CMD) --fix; \
1090-
fi
1087+
@$(call available-node,$(run-lint-js-fix))
10911088

10921089
.PHONY: lint-js
10931090
# Note that on the CI `lint-js-ci` is run instead.
10941091
# Lints the JavaScript code with eslint.
10951092
lint-js:
10961093
@echo "Running JS linter..."
1097-
@if [ -x $(NODE) ]; then \
1098-
$(NODE) $(LINT_JS_CMD); \
1099-
else \
1100-
node $(LINT_JS_CMD); \
1101-
fi
1094+
@$(call available-node,$(run-lint-js))
11021095

11031096
jslint: lint-js
11041097
@echo "Please use lint-js instead of jslint"
11051098

1099+
run-lint-js-ci = tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
1100+
$(LINT_JS_TARGETS)
1101+
11061102
.PHONY: lint-js-ci
11071103
# On the CI the output is emitted in the TAP format.
11081104
lint-js-ci:
11091105
@echo "Running JS linter..."
1110-
@if [ -x $(NODE) ]; then \
1111-
$(NODE) tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
1112-
$(LINT_JS_TARGETS); \
1113-
else \
1114-
node tools/lint-js.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \
1115-
$(LINT_JS_TARGETS); \
1116-
fi
1106+
@$(call available-node,$(run-lint-js-ci))
11171107

11181108
jslint-ci: lint-js-ci
11191109
@echo "Please use lint-js-ci instead of jslint-ci"

0 commit comments

Comments
 (0)