-
Notifications
You must be signed in to change notification settings - Fork 491
/
list-deps
executable file
·46 lines (38 loc) · 1.08 KB
/
list-deps
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
# Make sure we are in the dir of the script
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
cd $DIR
# List all dependent packages and whether they have been vendored.
deps() {
local package packages allDeps paths
# Get the current package
package=$(go list .)
# Get the sub packages excluding vendored packages
packages=$(go list ./... | grep -v "^$package/vendor")
allDeps=$(go list -f '{{ join .Deps "\n"}}' $packages)
for dep in $allDeps
do
# Skip standard lib deps
paths=(${dep//\// })
if ! [[ "${paths[0]}" =~ .*\..* ]]
then
continue
fi
# Skip deps from within current package
if [[ "$dep" =~ ^$package ]]
then
if [[ "$dep" =~ ^$package/vendor ]]
then
# Rewrite vendored deps as normal deps
dep="v ${dep/$package\/vendor\//}"
else
continue
fi
else
dep="n $dep"
fi
echo $dep
done
}
# Deduplicate and sort the output
deps | sort -k 2 -u