1+ # Sane defaults
2+ SHELL := /bin/bash
3+ .ONESHELL :
4+ .SHELLFLAGS := -eu -o pipefail -c
5+ .DELETE_ON_ERROR :
6+ MAKEFLAGS += --warn-undefined-variables
7+ MAKEFLAGS += --no-builtin-rules
8+
9+ # ---------------------- COMMANDS ---------------------------
10+ dev : # Start development server
11+ @echo " Starting development server.."
12+ cd public_html && python -m http.server 8000
13+
14+ format : # Format code with prettier
15+ @echo " Formatting code.."
16+ npx prettier --write --check .
17+
18+ # -----------------------------------------------------------
19+ # CAUTION: If you have a file with the same name as make
20+ # command, you need to add it to .PHONY below, otherwise it
21+ # won't work. E.g. `make run` wouldn't work if you have
22+ # `run` file in pwd.
23+ .PHONY : help
24+
25+ # -----------------------------------------------------------
26+ # ----- (Makefile helpers and decoration) --------
27+ # -----------------------------------------------------------
28+
29+ .DEFAULT_GOAL := help
30+ # check https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
31+ NC = \033[0m
32+ ERR = \033[31;1m
33+ TAB := '%-20s' # Increase if you have long commands
34+
35+ # tput colors
36+ red := $(shell tput setaf 1)
37+ green := $(shell tput setaf 2)
38+ yellow := $(shell tput setaf 3)
39+ blue := $(shell tput setaf 4)
40+ cyan := $(shell tput setaf 6)
41+ cyan80 := $(shell tput setaf 86)
42+ grey500 := $(shell tput setaf 244)
43+ grey300 := $(shell tput setaf 240)
44+ bold := $(shell tput bold)
45+ underline := $(shell tput smul)
46+ reset := $(shell tput sgr0)
47+
48+ help :
49+ @printf ' \n'
50+ @printf ' $(underline)Available make commands:$(reset)\n\n'
51+ @# Print commands with comments
52+ @grep -E ' ^([a-zA-Z0-9_-]+\.?)+:.+#.+$$' $(MAKEFILE_LIST ) \
53+ | grep -v ' ^env-' \
54+ | grep -v ' ^arg-' \
55+ | sed ' s/:.*#/: #/g' \
56+ | awk ' BEGIN {FS = "[: ]+#[ ]+"}; \
57+ {printf " make $( bold) $( TAB) $( reset) # %s\n" , \
58+ $$ 1, $$ 2}'
59+ @grep -E ' ^([a-zA-Z0-9_-]+\.?)+:( +\w+-\w+)*$$' $(MAKEFILE_LIST ) \
60+ | grep -v help \
61+ | awk ' BEGIN {FS = ":"}; \
62+ {printf " make $( bold) $( TAB) $( reset) \n" , \
63+ $$ 1}' || true
64+ @echo -e " "
0 commit comments