Skip to content

Commit a9f4526

Browse files
authored
Added a for-all make target (#126)
This allows to run the same command on all Go modules in the repository. For example, to update a single dependency in all modules, one can run: > make for-all CMD='go get github.com/[email protected]'
1 parent a108a80 commit a9f4526

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Makefile

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ include ./Makefile.Common
22

33
RUN_CONFIG=local/config.yaml
44

5+
CMD?=
56
GIT_SHA=$(shell git rev-parse --short HEAD)
67
BUILD_INFO_IMPORT_PATH=github.com/open-telemetry/opentelemetry-collector-contrib/internal/version
78
BUILD_X1=-X $(BUILD_INFO_IMPORT_PATH).GitHash=$(GIT_SHA)
@@ -43,11 +44,16 @@ test-with-cover:
4344

4445
.PHONY: gotidy
4546
gotidy:
46-
go mod tidy
47+
$(MAKE) for-all CMD="go mod tidy"
48+
49+
50+
.PHONY: for-all
51+
for-all:
52+
@$${CMD}
4753
@set -e; for dir in $(ALL_TEST_DIRS); do \
4854
(cd "$${dir}" && \
49-
echo "tidying up $${dir}" && \
50-
go mod tidy ); \
55+
echo "running $${CMD} in $${dir}" && \
56+
$${CMD} ); \
5157
done
5258

5359

0 commit comments

Comments
 (0)