mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Add any configured Go Workspace file to the config watcher
Fixes #10556
This commit is contained in:
parent
0d4b17d4c0
commit
6db527483d
4 changed files with 27 additions and 4 deletions
|
@ -924,6 +924,7 @@ func (c *commandeer) printChangeDetected(typ string) {
|
||||||
const (
|
const (
|
||||||
configChangeConfig = "config file"
|
configChangeConfig = "config file"
|
||||||
configChangeGoMod = "go.mod file"
|
configChangeGoMod = "go.mod file"
|
||||||
|
configChangeGoWork = "go work file"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
||||||
|
@ -943,6 +944,9 @@ func (c *commandeer) handleEvents(watcher *watcher.Batcher,
|
||||||
if strings.Contains(ev.Name, "go.mod") {
|
if strings.Contains(ev.Name, "go.mod") {
|
||||||
configChangeType = configChangeGoMod
|
configChangeType = configChangeGoMod
|
||||||
}
|
}
|
||||||
|
if strings.Contains(ev.Name, ".work") {
|
||||||
|
configChangeType = configChangeGoWork
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !isConfig {
|
if !isConfig {
|
||||||
// It may be one of the /config folders
|
// It may be one of the /config folders
|
||||||
|
|
|
@ -417,12 +417,18 @@ func (l configLoader) collectModules(modConfig modules.Config, v1 config.Provide
|
||||||
// Avoid recreating these later.
|
// Avoid recreating these later.
|
||||||
v1.Set("allModules", moduleConfig.ActiveModules)
|
v1.Set("allModules", moduleConfig.ActiveModules)
|
||||||
|
|
||||||
|
// We want to watch these for changes and trigger rebuild on version
|
||||||
|
// changes etc.
|
||||||
if moduleConfig.GoModulesFilename != "" {
|
if moduleConfig.GoModulesFilename != "" {
|
||||||
// We want to watch this for changes and trigger rebuild on version
|
|
||||||
// changes etc.
|
|
||||||
configFilenames = append(configFilenames, moduleConfig.GoModulesFilename)
|
configFilenames = append(configFilenames, moduleConfig.GoModulesFilename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if moduleConfig.GoWorkspaceFilename != "" {
|
||||||
|
configFilenames = append(configFilenames, moduleConfig.GoWorkspaceFilename)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return moduleConfig.ActiveModules, configFilenames, err
|
return moduleConfig.ActiveModules, configFilenames, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,9 +107,15 @@ func (h *Client) collect(tidy bool) (ModulesConfig, *collector) {
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
var workspaceFilename string
|
||||||
|
if h.ccfg.ModuleConfig.Workspace != WorkspaceDisabled {
|
||||||
|
workspaceFilename = h.ccfg.ModuleConfig.Workspace
|
||||||
|
}
|
||||||
|
|
||||||
return ModulesConfig{
|
return ModulesConfig{
|
||||||
AllModules: c.modules,
|
AllModules: c.modules,
|
||||||
GoModulesFilename: c.GoModulesFilename,
|
GoModulesFilename: c.GoModulesFilename,
|
||||||
|
GoWorkspaceFilename: workspaceFilename,
|
||||||
}, c
|
}, c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,6 +128,9 @@ type ModulesConfig struct {
|
||||||
|
|
||||||
// Set if this is a Go modules enabled project.
|
// Set if this is a Go modules enabled project.
|
||||||
GoModulesFilename string
|
GoModulesFilename string
|
||||||
|
|
||||||
|
// Set if a Go workspace file is configured.
|
||||||
|
GoWorkspaceFilename string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error {
|
func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error {
|
||||||
|
|
|
@ -15,6 +15,7 @@ package modules
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
@ -261,6 +262,9 @@ func decodeConfig(cfg config.Provider, pathReplacements map[string]string) (Conf
|
||||||
workingDir := cfg.GetString("workingDir")
|
workingDir := cfg.GetString("workingDir")
|
||||||
c.Workspace = filepath.Join(workingDir, c.Workspace)
|
c.Workspace = filepath.Join(workingDir, c.Workspace)
|
||||||
}
|
}
|
||||||
|
if _, err := os.Stat(c.Workspace); err != nil {
|
||||||
|
return c, fmt.Errorf("module workspace %q does not exist", c.Workspace)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue