mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
commands: Rename doWithCommandeer to cfgInit/cfgSetAndInit
This will make it clearer what it does and make the code more consistent.
This commit is contained in:
parent
898a0a96af
commit
8a5124d6b3
2 changed files with 11 additions and 11 deletions
|
@ -72,7 +72,7 @@ type commandeer struct {
|
||||||
|
|
||||||
visitedURLs *types.EvictingStringQueue
|
visitedURLs *types.EvictingStringQueue
|
||||||
|
|
||||||
doWithCommandeer func(c *commandeer) error
|
cfgInit func(c *commandeer) error
|
||||||
|
|
||||||
// We watch these for changes.
|
// We watch these for changes.
|
||||||
configFiles []string
|
configFiles []string
|
||||||
|
@ -152,7 +152,7 @@ func (c *commandeer) initFs(fs *hugofs.Fs) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f flagsToConfigHandler, doWithCommandeer func(c *commandeer) error, subCmdVs ...*cobra.Command) (*commandeer, error) {
|
func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f flagsToConfigHandler, cfgInit func(c *commandeer) error, subCmdVs ...*cobra.Command) (*commandeer, error) {
|
||||||
|
|
||||||
var rebuildDebouncer func(f func())
|
var rebuildDebouncer func(f func())
|
||||||
if running {
|
if running {
|
||||||
|
@ -171,7 +171,7 @@ func newCommandeer(mustHaveConfigFile, running bool, h *hugoBuilderCommon, f fla
|
||||||
h: h,
|
h: h,
|
||||||
ftch: f,
|
ftch: f,
|
||||||
commandeerHugoState: newCommandeerHugoState(),
|
commandeerHugoState: newCommandeerHugoState(),
|
||||||
doWithCommandeer: doWithCommandeer,
|
cfgInit: cfgInit,
|
||||||
visitedURLs: types.NewEvictingStringQueue(10),
|
visitedURLs: types.NewEvictingStringQueue(10),
|
||||||
debounce: rebuildDebouncer,
|
debounce: rebuildDebouncer,
|
||||||
fullRebuildSem: semaphore.NewWeighted(1),
|
fullRebuildSem: semaphore.NewWeighted(1),
|
||||||
|
@ -284,12 +284,12 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
doWithCommandeer := func(cfg config.Provider) error {
|
cfgSetAndInit := func(cfg config.Provider) error {
|
||||||
c.Cfg = cfg
|
c.Cfg = cfg
|
||||||
if c.doWithCommandeer == nil {
|
if c.cfgInit == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
err := c.doWithCommandeer(c)
|
err := c.cfgInit(c)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,7 +307,7 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
|
||||||
AbsConfigDir: c.h.getConfigDir(dir),
|
AbsConfigDir: c.h.getConfigDir(dir),
|
||||||
Environ: os.Environ(),
|
Environ: os.Environ(),
|
||||||
Environment: environment},
|
Environment: environment},
|
||||||
doWithCommandeer,
|
cfgSetAndInit,
|
||||||
doWithConfig)
|
doWithConfig)
|
||||||
|
|
||||||
if err != nil && mustHaveConfigFile {
|
if err != nil && mustHaveConfigFile {
|
||||||
|
@ -330,8 +330,8 @@ func (c *commandeer) loadConfig(mustHaveConfigFile, running bool) error {
|
||||||
|
|
||||||
// This is potentially double work, but we need to do this one more time now
|
// This is potentially double work, but we need to do this one more time now
|
||||||
// that all the languages have been configured.
|
// that all the languages have been configured.
|
||||||
if c.doWithCommandeer != nil {
|
if c.cfgInit != nil {
|
||||||
if err := c.doWithCommandeer(c); err != nil {
|
if err := c.cfgInit(c); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,9 +118,9 @@ func Execute(args []string) Response {
|
||||||
func initializeConfig(mustHaveConfigFile, running bool,
|
func initializeConfig(mustHaveConfigFile, running bool,
|
||||||
h *hugoBuilderCommon,
|
h *hugoBuilderCommon,
|
||||||
f flagsToConfigHandler,
|
f flagsToConfigHandler,
|
||||||
doWithCommandeer func(c *commandeer) error) (*commandeer, error) {
|
cfgInit func(c *commandeer) error) (*commandeer, error) {
|
||||||
|
|
||||||
c, err := newCommandeer(mustHaveConfigFile, running, h, f, doWithCommandeer)
|
c, err := newCommandeer(mustHaveConfigFile, running, h, f, cfgInit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue