-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
79 lines (61 loc) · 1.64 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Define variables
SHELLCHECK = shellcheck
BATS = bats
BPkg = bpkg
# Directories
SRC_DIR = ./
TEST_DIR = tests
# Targets
.PHONY: all lint test install_deps clean docs
# install_deps:
# @echo "Installing dependencies with bpkg..."
# @$(BPkg) install -g shellcheck || echo "shellcheck already installed"
# @$(BPkg) install -g bats-core/bats-core || echo "bats already installed"
format:
@echo "Formatting scripts..."
@shfmt -l -w *.sh
clean:
@echo "Cleaning up..."
@rm -rf $(TEST_DIR)/tmp
# Quality control
lint:
@echo "Running shellcheck on all scripts..."
@$(SHELLCHECK) -x $(SRC_DIR)/*.sh
test:
# bats isopod_shell_test.bats
@echo "Running bats tests..."
@$(BATS) $(TEST_DIR)
# Dependency installation
install_bpkg:
@echo "Installing bpkg..."
@curl -sLo- "https://get.bpkg.sh" | bash
pipx_installs:
@echo "Installing pipx packages..."
# dev support
@pipx install shelldoc
@pipx install md-to-html
winget_installs:
@echo "Installing winget packages..."
@winget install jqlang.jq
@winget install --id koalaman.shellcheck
npm_installs:
@echo "Installing npm packages..."
@npm install -g bats
go_installs:
@echo "Installing go packages..."
@go install mvdan.cc/sh/v3/cmd/shfmt@latest
# Generate documentation
docs:
@shelldoc -f *.sh
@for FILE in ./docs/*.md; do md-to-html --input "$$FILE" --output "$$FILE".html; done
open_docs:
if [ "$$(uname)" = "Linux" ]; then \
xdg-open ./docs/*.html; \
elif [ "$$(uname)" = "Darwin" ]; then \
open ./docs/*.html; \
elif [ "$$(uname | grep -i 'mingw\|msys\|cygwin')" ]; then \
start ./docs/*.html; \
else \
echo "Unsupported OS"; \
fi
check: format lint test docs