Created
July 31, 2018 11:49
-
-
Save QuanticPotatoes/1e9b4a41f00c91ffe016caa5bd1f1fbf to your computer and use it in GitHub Desktop.
Makefile template
This file contains 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
.PHONY: build test help | |
.DEFAULT_GOAL := help | |
NODE_ENV ?= development | |
help: | |
@grep -P '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | |
# If the first argument is one of the supported commands... | |
SUPPORTED_COMMANDS := npm restore-db-dev _restore_db_dev restore-db-prod _restore_db_prod build import_units import_users import_sections import_unit_sections | |
SUPPORTS_MAKE_ARGS := $(findstring $(firstword $(MAKECMDGOALS)), $(SUPPORTED_COMMANDS)) | |
ifneq "$(SUPPORTS_MAKE_ARGS)" "" | |
# use the rest as arguments for the command | |
COMMAND_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) | |
# ...and turn them into do-nothing targets | |
$(eval $(COMMAND_ARGS):;@:) | |
endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment