diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-04-09 09:07:22 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2021-04-09 09:07:22 +0300 |
commit | 9b83f45b6dcafa6e50df80a4786d6a36400a47fe (patch) | |
tree | 82083a96cfd17548a1282de90b4a4a301dbc7df5 /common | |
parent | 7fdd2b95e20f322b0a47f63ff1010a04f47ce67b (diff) |
Add complete dependency list in "hugo env -v"
Fixes #8400
Diffstat (limited to 'common')
-rw-r--r-- | common/hugo/hugo.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/common/hugo/hugo.go b/common/hugo/hugo.go index 1aae80776..6e94a8a33 100644 --- a/common/hugo/hugo.go +++ b/common/hugo/hugo.go @@ -18,6 +18,8 @@ import ( "html/template" "os" "path/filepath" + "runtime/debug" + "sort" "strings" "github.com/gohugoio/hugo/hugofs/files" @@ -107,3 +109,30 @@ func GetExecEnviron(workDir string, cfg config.Provider, fs afero.Fs) []string { return env } + +// GetDependencyList returns a sorted dependency list on the format package="version". +// It includes both Go dependencies and (a manually maintained) list of C(++) dependencies. +func GetDependencyList() []string { + var deps []string + + formatDep := func(path, version string) string { + return fmt.Sprintf("%s=%q", path, version) + } + + if IsExtended { + deps = append(deps, formatDep("github.com/sass/libsass", "3.6.4")) + } + + bi, ok := debug.ReadBuildInfo() + if !ok { + return deps + } + + for _, dep := range bi.Deps { + deps = append(deps, formatDep(dep.Path, dep.Version)) + } + + sort.Strings(deps) + + return deps +} |