mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-29 03:42:06 -05:00
commands: Add version time to "hugo config mounts"
This commit is contained in:
parent
6a365c2712
commit
6cd2110ab2
2 changed files with 18 additions and 0 deletions
|
@ -21,6 +21,7 @@ import (
|
||||||
"regexp"
|
"regexp"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/common/maps"
|
"github.com/gohugoio/hugo/common/maps"
|
||||||
|
|
||||||
|
@ -146,6 +147,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(&struct {
|
return json.Marshal(&struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
|
Time *time.Time `json:"time"`
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
Meta map[string]interface{} `json:"meta"`
|
Meta map[string]interface{} `json:"meta"`
|
||||||
|
@ -155,6 +157,7 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
|
||||||
}{
|
}{
|
||||||
Path: m.m.Path(),
|
Path: m.m.Path(),
|
||||||
Version: m.m.Version(),
|
Version: m.m.Version(),
|
||||||
|
Time: m.m.Time(),
|
||||||
Owner: ownerPath,
|
Owner: ownerPath,
|
||||||
Dir: m.m.Dir(),
|
Dir: m.m.Dir(),
|
||||||
Meta: config.Params,
|
Meta: config.Params,
|
||||||
|
@ -166,12 +169,14 @@ func (m *modMounts) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(&struct {
|
return json.Marshal(&struct {
|
||||||
Path string `json:"path"`
|
Path string `json:"path"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
|
Time *time.Time `json:"time"`
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
Dir string `json:"dir"`
|
Dir string `json:"dir"`
|
||||||
Mounts []modMount `json:"mounts"`
|
Mounts []modMount `json:"mounts"`
|
||||||
}{
|
}{
|
||||||
Path: m.m.Path(),
|
Path: m.m.Path(),
|
||||||
Version: m.m.Version(),
|
Version: m.m.Version(),
|
||||||
|
Time: m.m.Time(),
|
||||||
Owner: ownerPath,
|
Owner: ownerPath,
|
||||||
Dir: m.m.Dir(),
|
Dir: m.m.Dir(),
|
||||||
Mounts: mounts,
|
Mounts: mounts,
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
package modules
|
package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/gohugoio/hugo/config"
|
"github.com/gohugoio/hugo/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -65,6 +67,9 @@ type Module interface {
|
||||||
// The module version.
|
// The module version.
|
||||||
Version() string
|
Version() string
|
||||||
|
|
||||||
|
// Time version was created.
|
||||||
|
Time() *time.Time
|
||||||
|
|
||||||
// Whether this module's dir is a watch candidate.
|
// Whether this module's dir is a watch candidate.
|
||||||
Watch() bool
|
Watch() bool
|
||||||
}
|
}
|
||||||
|
@ -154,6 +159,14 @@ func (m *moduleAdapter) Version() string {
|
||||||
return m.gomod.Version
|
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 {
|
func (m *moduleAdapter) Watch() bool {
|
||||||
if m.Owner() == nil {
|
if m.Owner() == nil {
|
||||||
// Main project
|
// Main project
|
||||||
|
|
Loading…
Reference in a new issue