Skip to content

Commit 157739b

Browse files
committedNov 25, 2024
update makefile to check and install tools separately
Signed-off-by: Andres Taylor <andres@planetscale.com>
1 parent ed5d20c commit 157739b

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed
 

‎Makefile

+20-15
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,33 @@ clean:
3232
rm -f vt
3333

3434
# Pretty: formats the code using gofumpt and goimports-reviser
35-
pretty: install-tools
35+
pretty: check-tools
3636
@echo "Running formatting tools..."
3737
@gofumpt -l -w . >/dev/null 2>&1 || true
3838
@goimports-reviser -project-name $$(go list -m) -rm-unused -set-alias -format . >/dev/null 2>&1 || true
3939

40-
# Install tools: Checks if the required tools are installed, installs if missing
40+
# Tools installation command
4141
install-tools:
42-
@command -v gofumpt >/dev/null 2>&1 || { \
43-
echo "Installing gofumpt..."; \
44-
go install mvdan.cc/gofumpt@latest >/dev/null 2>&1; \
45-
}
46-
@command -v goimports-reviser >/dev/null 2>&1 || { \
47-
echo "Installing goimports-reviser..."; \
48-
go install github.com/incu6us/goimports-reviser@latest >/dev/null 2>&1; \
49-
}
50-
@command -v golangci-lint >/dev/null 2>&1 || { \
51-
echo "Installing golangci-lint..."; \
52-
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin $(GOLANGCI_LINT_VERSION); \
53-
}
42+
@echo "Installing gofumpt..."
43+
go install mvdan.cc/gofumpt@latest
44+
45+
@echo "Installing goimports-reviser..."
46+
go install github.com/incu6us/goimports-reviser/v3@latest
47+
48+
@echo "Installing golangci-lint..."
49+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
50+
51+
@echo "All tools installed successfully."
52+
53+
# Ensure tools are available
54+
check-tools:
55+
@command -v gofumpt >/dev/null 2>&1 || { echo "gofumpt not found. Run 'make install-tools' to install it." >&2; exit 1; }
56+
@command -v goimports-reviser >/dev/null 2>&1 || { echo "goimports-reviser not found. Run 'make install-tools' to install it." >&2; exit 1; }
57+
@command -v golangci-lint >/dev/null 2>&1 || { echo "golangci_lint not found. Run 'make install-tools' to install it." >&2; exit 1; }
58+
5459

5560
# Lint: runs golangci-lint
56-
lint: install-tools
61+
lint: check-tools
5762
@echo "Running golangci-lint..."
5863
@golangci-lint run --config .golangci.yml ./go/...
5964

0 commit comments

Comments
 (0)