-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (30 loc) · 1.68 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
SHELL := /bin/bash
all:
@echo 'Type "make help" to see the help menu.'
help: ## Prints this help menu
@cat $(MAKEFILE_LIST) | grep -E '^[a-zA-Z_-]+:.*?## .*$$' | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
install: ## Installs wdt
@if [[ ! -d $$HOME/.local/bin ]]; then mkdir -p $$HOME/.local/bin && \
echo 'Created ~/.local/bin. Please add it to $$PATH and run "make install" again.'; \
else if [[ ! :$$PATH: == *":$$HOME/.local/bin:"* ]]; \
then echo 'Please add ~/.local/bin to $$PATH.'; \
else cp ./wdt $$HOME/.local/bin/ && echo "WDT installed successfully."; \
fi; fi
uninstall: ## Uninstalls wdt
@if [[ -f $$HOME/.local/bin/wdt ]]; then rm $$HOME/.local/bin/wdt && \
echo "WDT uninstalled successfully."; else echo "WDT not found."; fi
container: ## Build a docker container for testing
@if ! command -v docker > /dev/null; then echo "Docker not found, install it first"; \
elif [[ $$(docker images | grep wdttest) ]]; then \
echo 'Container "wdttest" already exists'; else echo 'Building the "wdttest" container' \
&& docker build -t wdttest . && echo "Built successfully"; fi
delcontainer:
@if [[ $$(docker images | grep wdttest) ]]; then echo 'Deleting "wdttest" container' && \
docker image rm wdttest:latest -f; \
else echo 'Container "wdttest" not found. Build it with \`make container\`.'; fi
rebuild: delcontainer container ## Rebuild existing docker container
test: ## Run the wdttest container
@if [[ $$(docker images | grep wdttest) ]]; then docker run -it wdttest; \
else echo 'Container "wdttest" not found. Build it with \`make container\`.'; fi
.PHONY: all help install uninstall container delcontainer rebuild test