Skip to content

Commit

Permalink
commands: Add version time to "hugo config mounts"
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Jun 27, 2021
1 parent 6a365c2 commit 6cd2110
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"regexp"
"sort"
"strings"
"time"

"github.com/gohugoio/hugo/common/maps"

Expand Down Expand Up @@ -146,6 +147,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Path string `json:"path"`
Version string `json:"version"`
Time *time.Time `json:"time"`
Owner string `json:"owner"`
Dir string `json:"dir"`
Meta map[string]interface{} `json:"meta"`
Expand All @@ -155,6 +157,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
}{
Path: m.m.Path(),
Version: m.m.Version(),
Time: m.m.Time(),
Owner: ownerPath,
Dir: m.m.Dir(),
Meta: config.Params,
Expand All @@ -166,12 +169,14 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
return json.Marshal(&struct {
Path string `json:"path"`
Version string `json:"version"`
Time *time.Time `json:"time"`
Owner string `json:"owner"`
Dir string `json:"dir"`
Mounts []modMount `json:"mounts"`
}{
Path: m.m.Path(),
Version: m.m.Version(),
Time: m.m.Time(),
Owner: ownerPath,
Dir: m.m.Dir(),
Mounts: mounts,
Expand Down
13 changes: 13 additions & 0 deletions modules/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package modules

import (
"time"

"github.com/gohugoio/hugo/config"
)

Expand Down Expand Up @@ -65,6 +67,9 @@ type Module interface {
// The module version.
Version() string

// Time version was created.
Time() *time.Time

// Whether this module's dir is a watch candidate.
Watch() bool
}
Expand Down Expand Up @@ -154,6 +159,14 @@ func (m *moduleAdapter) Version() string {
return m.gomod.Version
}

func (m *moduleAdapter) Time() *time.Time {
if !m.IsGoMod() || m.gomod.Time == nil {
return nil
}

return m.gomod.Time
}

func (m *moduleAdapter) Watch() bool {
if m.Owner() == nil {
// Main project
Expand Down

0 comments on commit 6cd2110

Please sign in to comment.