Skip to content

Instantly share code, notes, and snippets.

@QuanticPotatoes
Created July 31, 2018 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save QuanticPotatoes/1e9b4a41f00c91ffe016caa5bd1f1fbf to your computer and use it in GitHub Desktop.
Save QuanticPotatoes/1e9b4a41f00c91ffe016caa5bd1f1fbf to your computer and use it in GitHub Desktop.
Makefile template
.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