diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/client.go | 9 | ||||
-rw-r--r-- | modules/client_test.go | 6 | ||||
-rw-r--r-- | modules/collect.go | 5 |
3 files changed, 15 insertions, 5 deletions
diff --git a/modules/client.go b/modules/client.go index c66311d05..914d06a4e 100644 --- a/modules/client.go +++ b/modules/client.go @@ -605,8 +605,9 @@ type ClientConfig struct { // etc. HookBeforeFinalize func(m *ModulesConfig) error - // Ignore any _vendor directory. - IgnoreVendor bool + // Ignore any _vendor directory for module paths matching the given pattern. + // This can be nil. + IgnoreVendor glob.Glob // Absolute path to the project dir. WorkingDir string @@ -618,6 +619,10 @@ type ClientConfig struct { ModuleConfig Config } +func (c ClientConfig) shouldIgnoreVendor(path string) bool { + return c.IgnoreVendor != nil && c.IgnoreVendor.Match(path) +} + type goBinaryStatus int type goModule struct { diff --git a/modules/client_test.go b/modules/client_test.go index 07b71c409..d5da621d1 100644 --- a/modules/client_test.go +++ b/modules/client_test.go @@ -17,6 +17,8 @@ import ( "bytes" "testing" + "github.com/gohugoio/hugo/hugofs/glob" + "github.com/gohugoio/hugo/common/hugo" "github.com/gohugoio/hugo/htesting" @@ -89,7 +91,7 @@ project github.com/gohugoio/hugoTestModules1_darwin/modh2_2_2@v1.3.0+vendor Fs: hugofs.Os, WorkingDir: workingDir, ModuleConfig: modConfig, - IgnoreVendor: true, + IgnoreVendor: globAll, }) graphb.Reset() @@ -101,6 +103,8 @@ project github.com/gohugoio/hugoTestModules1_darwin/modh2_2_2@v1.3.0+vendor } +var globAll, _ = glob.GetGlob("**") + func TestGetModlineSplitter(t *testing.T) { c := qt.New(t) diff --git a/modules/collect.go b/modules/collect.go index 0ac766fb9..f87ed2484 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -196,7 +196,8 @@ func (c *collector) initModules() error { gomods: goModules{}, } - if !c.ccfg.IgnoreVendor && c.isVendored(c.ccfg.WorkingDir) { + // If both these are true, we don't even need Go installed to build. + if c.ccfg.IgnoreVendor == nil && c.isVendored(c.ccfg.WorkingDir) { return nil } @@ -229,7 +230,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool modulePath := moduleImport.Path var realOwner Module = owner - if !c.ccfg.IgnoreVendor { + if !c.ccfg.shouldIgnoreVendor(modulePath) { if err := c.collectModulesTXT(owner); err != nil { return nil, err } |