From 57f12c366020c97c2d4e427dbaec77e841176361 Mon Sep 17 00:00:00 2001 From: Ray Wang Date: Thu, 3 Dec 2020 17:29:26 +0800 Subject: [PATCH] Better module checking/initializing mechanism 1. Print a message to tell if modules need to be initialized when running `make serve` or other similar targets, and stop current make procedure. 2. Provide `module-init` target to initialize all dependencies Co-authored-by: Tim Bannister --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 58babc3627..a05c18aea2 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,11 @@ help: ## Show this help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) module-check: - @git submodule status --recursive | awk '/^[+-]/ {printf "\033[31mWARNING\033[0m Submodule not initialized: \033[34m%s\033[0m\n",$$2}' 1>&2 + @git submodule status --recursive | awk '/^[+-]/ {err = 1; printf "\033[31mWARNING\033[0m Submodule not initialized: \033[34m%s\033[0m\n",$$2} END { if (err != 0) print "You need to run \033[32mmake module-init\033[0m to initialize missing modules first"; exit err }' 1>&2 + +module-init: + @echo "Initializing submodules..." 1>&2 + @git submodule update --init --recursive --depth 1 all: build ## Build site with production settings and put deliverables in ./public