diff options
Diffstat (limited to 'modules/collect.go')
-rw-r--r-- | modules/collect.go | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/modules/collect.go b/modules/collect.go index fcde1d379..c69e7e7ee 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -52,20 +52,6 @@ func IsNotExist(err error) bool { return errors.Is(err, os.ErrNotExist) } -// CreateProjectModule creates modules from the given config. -// This is used in tests only. -func CreateProjectModule(cfg config.Provider) (Module, error) { - workingDir := cfg.GetString("workingDir") - var modConfig Config - - mod := createProjectModule(nil, workingDir, modConfig) - if err := ApplyProjectConfigDefaults(cfg, mod); err != nil { - return nil, err - } - - return mod, nil -} - func (h *Client) Collect() (ModulesConfig, error) { mc, coll := h.collect(true) if coll.err != nil { @@ -90,6 +76,9 @@ func (h *Client) Collect() (ModulesConfig, error) { } func (h *Client) collect(tidy bool) (ModulesConfig, *collector) { + if h == nil { + panic("nil client") + } c := &collector{ Client: h, } @@ -133,6 +122,16 @@ type ModulesConfig struct { GoWorkspaceFilename string } +func (m ModulesConfig) HasConfigFile() bool { + for _, mod := range m.ActiveModules { + if len(mod.ConfigFilenames()) > 0 { + return true + } + + } + return false +} + func (m *ModulesConfig) setActiveMods(logger loggers.Logger) error { var activeMods Modules for _, mod := range m.AllModules { @@ -230,6 +229,7 @@ func (c *collector) getVendoredDir(path string) (vendoredModule, bool) { } func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool) (*moduleAdapter, error) { + var ( mod *goModule moduleDir string @@ -299,7 +299,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool return nil, nil } if found, _ := afero.Exists(c.fs, moduleDir); !found { - c.err = c.wrapModuleNotFound(fmt.Errorf(`module %q not found; either add it as a Hugo Module or store it in %q.`, modulePath, c.ccfg.ThemesDir)) + c.err = c.wrapModuleNotFound(fmt.Errorf(`module %q not found in % q; either add it as a Hugo Module or store it in %q.`, modulePath, moduleDir, c.ccfg.ThemesDir)) return nil, nil } } @@ -347,7 +347,7 @@ func (c *collector) addAndRecurse(owner *moduleAdapter, disabled bool) error { moduleConfig := owner.Config() if owner.projectMod { if err := c.applyMounts(Import{}, owner); err != nil { - return err + return fmt.Errorf("failed to apply mounts for project module: %w", err) } } @@ -618,7 +618,7 @@ func (c *collector) mountCommonJSConfig(owner *moduleAdapter, mounts []Mount) ([ // Mount the common JS config files. fis, err := afero.ReadDir(c.fs, owner.Dir()) if err != nil { - return mounts, err + return mounts, fmt.Errorf("failed to read dir %q: %q", owner.Dir(), err) } for _, fi := range fis { |