Skip to content

Tooling: Add setup-pre-commit make target #145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Follow our [Getting Started Guide](https://github.com/nginxinc/nginx-hugo-theme/
We use [pre-commit](https://pre-commit.com/#install) for local pre-commit hooks.
To get setup:
- Install [pre-commit ](https://pre-commit.com/#install)
- Install the hooks `pre-commit install`
- Run the make target `make setup-pre-commit`

### Report a Bug

Expand Down
14 changes: 12 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ list help::
@echo " biome-all: Runs both the lint and formatting commands."
@echo " (Set BIOME_ARGS to add additional arguments to biome command (ex: make biome-all BIOME_ARGS=write))"

.PHONY: biome-format biome-lint biome-all
.PHONY: biome-format biome-lint biome-all setup-pre-commit
BIOME_ARGS ?=
FLAG :=
ifeq ($(BIOME_ARGS), write)
Expand All @@ -25,4 +25,14 @@ biome-format:
biome-lint:
$(BIOME_BASE_CMD) lint $(BIOME_CONFIG_PATH) $(FLAG)
biome-all:
$(BIOME_BASE_CMD) check $(BIOME_CONFIG_PATH) $(FLAG)
$(BIOME_BASE_CMD) check $(BIOME_CONFIG_PATH) $(FLAG)

setup-pre-commit:
@if ! command -v pre-commit &> /dev/null; then \
echo "WARNING: 'pre-commit' is not installed. Please install it using: pip install pre-commit or brew install pre-commit"; \
else \
echo "pre-commit is installed! Proceeding with hook installation."; \
pre-commit install; \
pre-commit install --hook-type commit-msg; \
echo "pre-commit hooks have been successfully installed."; \
fi