From d4611c4322dabfd8d2520232be578388029867db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Wed, 9 Sep 2020 21:10:28 +0200 Subject: modules: Add noVendor to module config Fixes #7647 --- modules/client.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'modules/client.go') diff --git a/modules/client.go b/modules/client.go index 86f8a2caa..d71c48f0c 100644 --- a/modules/client.go +++ b/modules/client.go @@ -26,9 +26,10 @@ import ( "path/filepath" "regexp" - "github.com/gobwas/glob" hglob "github.com/gohugoio/hugo/hugofs/glob" + "github.com/gobwas/glob" + "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugofs/files" @@ -100,10 +101,16 @@ func NewClient(cfg ClientConfig) *Client { logger = loggers.NewWarningLogger() } + var noVendor glob.Glob + if cfg.ModuleConfig.NoVendor != "" { + noVendor, _ = hglob.GetGlob(hglob.NormalizePath(cfg.ModuleConfig.NoVendor)) + } + return &Client{ fs: fs, ccfg: cfg, logger: logger, + noVendor: noVendor, moduleConfig: mcfg, environ: env, GoModulesFilename: goModFilename} @@ -114,6 +121,8 @@ type Client struct { fs afero.Fs logger *loggers.Logger + noVendor glob.Glob + ccfg ClientConfig // The top level module config @@ -220,6 +229,10 @@ func (c *Client) Vendor() error { continue } + if !c.shouldVendor(t.Path()) { + continue + } + if !t.IsGoMod() && !t.Vendor() { // We currently do not vendor components living in the // theme directory, see https://github.com/gohugoio/hugo/issues/5993 @@ -596,6 +609,10 @@ func (c *Client) tidy(mods Modules, goModOnly bool) error { return nil } +func (c *Client) shouldVendor(path string) bool { + return c.noVendor == nil || !c.noVendor.Match(path) +} + // ClientConfig configures the module Client. type ClientConfig struct { Fs afero.Fs -- cgit v1.2.3