diff options
Diffstat (limited to 'commands/commandeer.go')
-rw-r--r-- | commands/commandeer.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index 59fe32f74..f18a95bb9 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -48,6 +48,7 @@ import ( "github.com/gohugoio/hugo/helpers" "github.com/gohugoio/hugo/hugofs" "github.com/gohugoio/hugo/hugolib" + "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/resources/kinds" "github.com/spf13/afero" "github.com/spf13/cobra" @@ -103,6 +104,9 @@ type rootCommand struct { commonConfigs *lazycache.Cache[int32, *commonConfig] hugoSites *lazycache.Cache[int32, *hugolib.HugoSites] + // changesFromBuild received from Hugo in watch mode. + changesFromBuild chan []identity.Identity + commands []simplecobra.Commander // Flags @@ -304,7 +308,7 @@ func (r *rootCommand) ConfigFromProvider(key int32, cfg config.Provider) (*commo func (r *rootCommand) HugFromConfig(conf *commonConfig) (*hugolib.HugoSites, error) { h, _, err := r.hugoSites.GetOrCreate(r.configVersionID.Load(), func(key int32) (*hugolib.HugoSites, error) { - depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, LogOut: r.logger.Out(), LogLevel: r.logger.Level()} + depsCfg := r.newDepsConfig(conf) return hugolib.NewHugoSites(depsCfg) }) return h, err @@ -316,12 +320,16 @@ func (r *rootCommand) Hugo(cfg config.Provider) (*hugolib.HugoSites, error) { if err != nil { return nil, err } - depsCfg := deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, LogOut: r.logger.Out(), LogLevel: r.logger.Level()} + depsCfg := r.newDepsConfig(conf) return hugolib.NewHugoSites(depsCfg) }) return h, err } +func (r *rootCommand) newDepsConfig(conf *commonConfig) deps.DepsCfg { + return deps.DepsCfg{Configs: conf.configs, Fs: conf.fs, LogOut: r.logger.Out(), LogLevel: r.logger.Level(), ChangesFromBuild: r.changesFromBuild} +} + func (r *rootCommand) Name() string { return "hugo" } @@ -408,6 +416,8 @@ func (r *rootCommand) PreRun(cd, runner *simplecobra.Commandeer) error { return err } + r.changesFromBuild = make(chan []identity.Identity, 10) + r.commonConfigs = lazycache.New(lazycache.Options[int32, *commonConfig]{MaxEntries: 5}) // We don't want to keep stale HugoSites in memory longer than needed. r.hugoSites = lazycache.New(lazycache.Options[int32, *hugolib.HugoSites]{ |