-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcore.node.mk
24 lines (20 loc) · 953 Bytes
/
core.node.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# ------------------------------------------------------------------------------
# makefile-folder node_modules exebutables
PATH_NPM := $(MAKE_PATH)/node_modules/.bin
# repository node_modules executables
PATH_NPM := $(PATH_NPM):$(GIT_ROOT)/node_modules/.bin
define npm-which
$(shell \
export PATH="$(PATH_NPM):$(PATH)"; \
hash -r; \
export RESULT="$$(for CMD in $(2); do $(COMMAND_Q) $${CMD} && break || continue; done)"; \
$(ECHO) "$${RESULT:-$(1)_NOT_FOUND}")
endef
NODE = $(call which,NODE,node)
NODE_ESM = $(call which,NODE_ESM,node-esm)
NODE_NPM = $(shell $(REALPATH) $(NODE) | $(SED) "s/bin\/node\$$/libexec\/npm\/bin\/npm/")
NODE_NPX = $(shell $(REALPATH) $(NODE) | $(SED) "s/bin\/node\$$/libexec\/npm\/bin\/npx/")
NPM = $(call which,NPM,npm)
NPX = $(call which,NPX,npx)
$(foreach VAR,NODE NODE_ESM NODE_NPM NODE_NPX NPM NPX,$(call make-lazy-once,$(VAR)))
# ------------------------------------------------------------------------------