diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-09-09 21:10:28 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2020-09-10 08:47:05 +0200 |
commit | d4611c4322dabfd8d2520232be578388029867db (patch) | |
tree | c68d7e14430b1f65021af6742b27a5496eb4aea4 /modules/client.go | |
parent | 20af9a078189ce1e92a1d2047c90fba2a4e91827 (diff) |
modules: Add noVendor to module config
Fixes #7647
Diffstat (limited to 'modules/client.go')
-rw-r--r-- | modules/client.go | 19 |
1 files changed, 18 insertions, 1 deletions
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 |