Skip to content

Commit e96089e

Browse files
authored
Merge pull request #151 from target/deps-reqs-versions
Replace make does-path-have-reqs with better deps-reqs-versions
2 parents 4da6aa3 + bf55d13 commit e96089e

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

Makefile

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,30 @@ install-precommit: $(GIT_HOOKS) ## Sets up pre-commit hooks
172172
$(GIT_HOOKS): .pre-commit-config.yaml
173173
$(PRECOMMIT) install
174174

175-
.PHONY: does-path-have-reqs
176-
does-path-have-reqs: ## Check if shell $PATH has expected elements
177-
@echo "$(COLOR_BLUE)Checking PATH elements for evidence of package managers…$(COLOR_RESET)"
178-
@( (echo $${PATH} | grep -q poetry ) && echo "found poetry") || (echo "missing poetry" && false)
179-
@( (echo $${PATH} | grep -q homebrew ) && echo "found homebrew") || (echo "missing homebrew" && false)
180-
@( (echo $${PATH} | grep -q pyenv ) && echo "found pyenv") || (echo "missing pyenv" && false)
175+
.PHONY: deps-reqs-versions
176+
deps-reqs-versions: ## Check if shell $PATH has requirements and show their version
177+
@echo "$(COLOR_BLUE)Checking PATH elements for evidence of required tools. The first in each section is what's used.$(COLOR_RESET)"
178+
@$(MAKE) paths-version-for-cmd CMD=poetry
179+
@$(MAKE) paths-version-for-cmd CMD=pyenv
180+
@$(MAKE) paths-version-for-cmd CMD=brew
181+
@$(MAKE) paths-version-for-cmd CMD=curl
182+
@$(MAKE) paths-version-for-cmd CMD=git
183+
@$(MAKE) paths-version-for-cmd CMD=pre-commit
181184
@echo "$(COLOR_GREEN)All expected PATH elements found$(COLOR_RESET)"
182185

186+
CMD_VERSION_FLAG ?= --version
187+
WHICH ?= which
188+
.PHONY: paths-version-for-cmd
189+
paths-version-for-cmd: ## Display version for all executable paths for an executable, set CMD & CMD_VERSION_FLAG
190+
@( if [ -z "$$(which -a $(CMD))" ]; then \
191+
echo "==> $(COLOR_RED)missing $(CMD)$(COLOR_RESET)"; \
192+
else \
193+
echo "==> $(COLOR_ORANGE)$(CMD) $(COLOR_BLUE)commands' versions are:$(COLOR_RESET)"; \
194+
for pth in $$($(WHICH) -a $(CMD)); do \
195+
echo "$(COLOR_BLUE)$${pth}$(COLOR_RESET) : $$("$${pth}" $(CMD_VERSION_FLAG))"; \
196+
done; \
197+
fi )
198+
183199
##@ Dependencies
184200

185201
.PHONY: python-current

0 commit comments

Comments
 (0)