Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7979fdb

Browse files
committed
add list-external-deps
1 parent b3f6bc4 commit 7979fdb

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

Makefile

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ SOURCE ?= file go-bindata github
22
DATABASE ?= postgres
33
VERSION ?= $(shell git describe --tags 2>/dev/null)
44
TEST_FLAGS ?=
5+
REPO_OWNER ?= $(shell cd .. && basename "$$(pwd)")
56

67

78
build-cli: clean
@@ -39,12 +40,12 @@ test-with-flags:
3940
@go test $(TEST_FLAGS) ./testing/...
4041

4142
@echo -n '$(SOURCE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./source/{}
42-
@go test $(TEST_FLAGS) ./source/testing
43-
@go test $(TEST_FLAGS) ./source/stub
43+
@go test $(TEST_FLAGS) ./source/testing/...
44+
@go test $(TEST_FLAGS) ./source/stub/...
4445

4546
@echo -n '$(DATABASE)' | tr -s ' ' '\n' | xargs -I{} go test $(TEST_FLAGS) ./database/{}
46-
@go test $(TEST_FLAGS) ./database/testing
47-
@go test $(TEST_FLAGS) ./database/stub
47+
@go test $(TEST_FLAGS) ./database/testing/...
48+
@go test $(TEST_FLAGS) ./database/stub/...
4849

4950
# deprecated v1compat:
5051
@go test ./migrate/...
@@ -59,16 +60,37 @@ deps:
5960
-go test -v -i ./...
6061

6162

63+
list-external-deps:
64+
$(call external_deps,'.')
65+
$(call external_deps,'./cli/...')
66+
$(call external_deps,'./testing/...')
67+
68+
$(foreach v, $(SOURCE), $(call external_deps,'./source/$(v)/...'))
69+
$(call external_deps,'./source/testing/...')
70+
$(call external_deps,'./source/stub/...')
71+
72+
$(foreach v, $(DATABASE), $(call external_deps,'./database/$(v)/...'))
73+
$(call external_deps,'./database/testing/...')
74+
$(call external_deps,'./database/stub/...')
75+
76+
6277
restore-import-paths:
63-
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#\"github.com/mattes/migrate#g '{}' \;
78+
find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/$(REPO_OWNER)/migrate%\"github.com/mattes/migrate%g '{}' \;
6479

6580

6681
rewrite-import-paths:
67-
find . -name '*.go' -type f -execdir sed -i '' s#\"github.com/mattes/migrate#\"github.com/$(shell cd .. && basename "$$(pwd)")/migrate#g '{}' \;
82+
find . -name '*.go' -type f -execdir sed -i '' s%\"github.com/mattes/migrate%\"github.com/$(REPO_OWNER)/migrate%g '{}' \;
83+
84+
85+
define external_deps
86+
@echo -- $(1)
87+
@go list -f '{{join .Deps "\n"}}' $(1) | grep -v github.com/$(REPO_OWNER)/migrate | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}'
88+
@#\n
89+
endef
6890

6991

7092
.PHONY: build-cli clean test-short test test-with-flags deps html-coverage \
71-
restore-import-paths rewrite-import-paths
93+
restore-import-paths rewrite-import-paths list-external-deps
7294

7395
SHELL = /bin/bash
7496
RAND = $(shell echo $$RANDOM)

0 commit comments

Comments
 (0)