Created
February 9, 2020 10:58
-
-
Save micklove/c2c9cfaf74baf2e0e269007314d11ede to your computer and use it in GitHub Desktop.
make for executing npm scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use jq to grab the various scripts from package.json and expose them as a make targets | |
# Based on the awesome script from https://gist.github.com/kvz/79554af7f2d1b1379536 | |
# (but with jq... for something different) | |
# can use autocomplete (make <TAB><TAB> ) | |
TARGETS:=$(shell jq -r ".scripts | keys | .[]" package.json | sed 's/:/-/g') | |
define npm_script_targets | |
$$(TARGETS): | |
npm run $(subst -,:,$(MAKECMDGOALS)) | |
.PHONY: $$(TARGETS) | |
endef | |
$(eval $(call npm_script_targets)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment