From be4dac5db20e3fce1bf61f18ab7e9809fca5bb2a Mon Sep 17 00:00:00 2001 From: bupd Date: Fri, 15 Nov 2024 16:44:46 +0530 Subject: [PATCH] add check_hugo_version to makefile * Adds checking of current hugo version installed * checks the current hugo version installed and verifies if the correct hugo version required is installed before serve. * adds .tool-versions to gitignore - an autogenerated file by asdf. Signed-off-by: bupd --- .gitignore | 1 + Makefile | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c23fd50ca..02be9a4e3 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ Thumbs.db *.un~ .idea/ .hugo_build.lock +.tool-versions diff --git a/Makefile b/Makefile index 62e4e6dee..8daa32693 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,23 @@ +HUGO_VERSION_REQUIRED="v0.74.0" +EXTENDED_REQUIRED="extended" + +check_hugo_version: + @version=$$(hugo version | head -n 1 | awk '{print $$5}' | sed 's/-.*//'); \ + extended=$$(hugo version | head -n 1 | grep -o 'extended'); \ + if [ "$$version" != "$(HUGO_VERSION_REQUIRED)" ] || [ "$$extended" != "$(EXTENDED_REQUIRED)" ]; then \ + echo "Error: Current Hugo version is $$version. AND is not $(HUGO_VERSION_REQUIRED) extended version."; \ + exit 1; \ + else \ + echo "Hugo version $$version is correct and is extended version."; \ + fi + clean: rm -rf public resources prepare: $(CURDIR)/load-docs.sh -serve: +serve: check_hugo_version hugo server \ --bind 0.0.0.0 \ --buildDrafts \