aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2022-12-19 17:49:45 +0100
committerBjørn Erik Pedersen <[email protected]>2022-12-19 20:17:33 +0100
commit330fa8941152108327504b511c563dacfc3f4c75 (patch)
treea532ed1c77666714792dc8481624fedda9901d2b /modules
parent6db527483dec048fbcc5735c41b137a8eb6508e4 (diff)
downloadhugo-330fa8941152108327504b511c563dacfc3f4c75.tar.gz
hugo-330fa8941152108327504b511c563dacfc3f4c75.zip
modules: Adjust watch logic vs workspace use definitions
Diffstat (limited to 'modules')
-rw-r--r--modules/config_test.go14
-rw-r--r--modules/module.go4
2 files changed, 14 insertions, 4 deletions
diff --git a/modules/config_test.go b/modules/config_test.go
index 4ded2be66..5c97caaa2 100644
--- a/modules/config_test.go
+++ b/modules/config_test.go
@@ -14,6 +14,9 @@
package modules
import (
+ "fmt"
+ "os"
+ "path/filepath"
"testing"
"github.com/gohugoio/hugo/common/hugo"
@@ -43,8 +46,9 @@ func TestDecodeConfig(t *testing.T) {
c := qt.New(t)
c.Run("Basic", func(c *qt.C) {
+ tempDir := c.TempDir()
tomlConfig := `
-workingDir = "/src/project"
+workingDir = %q
[module]
workspace = "hugo.work"
[module.hugoVersion]
@@ -65,7 +69,11 @@ source="src/markdown/blog"
target="content/blog"
lang="en"
`
- cfg, err := config.FromConfigString(tomlConfig, "toml")
+
+ hugoWorkFilename := filepath.Join(tempDir, "hugo.work")
+ f, _ := os.Create(hugoWorkFilename)
+ f.Close()
+ cfg, err := config.FromConfigString(fmt.Sprintf(tomlConfig, tempDir), "toml")
c.Assert(err, qt.IsNil)
mcfg, err := DecodeConfig(cfg)
@@ -83,7 +91,7 @@ lang="en"
c.Assert(hv.IsValid(), qt.Equals, true)
}
- c.Assert(mcfg.Workspace, qt.Equals, "/src/project/hugo.work")
+ c.Assert(mcfg.Workspace, qt.Equals, hugoWorkFilename)
c.Assert(len(mcfg.Mounts), qt.Equals, 1)
c.Assert(len(mcfg.Imports), qt.Equals, 1)
diff --git a/modules/module.go b/modules/module.go
index 0d094fe87..42bd94e7b 100644
--- a/modules/module.go
+++ b/modules/module.go
@@ -184,5 +184,7 @@ func (m *moduleAdapter) Watch() bool {
return m.Replace().Version() == ""
}
- return false
+ // Any module set up in a workspace file will have Indirect set to false.
+ // That leaves modules inside the read-only module cache.
+ return !m.gomod.Indirect
}