diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-25 19:48:28 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-03-27 15:43:56 +0200 |
commit | ee4a33b14ff2b0a2d9130415e16d1046f72573f7 (patch) | |
tree | fa0ef27ca1818dadb59f9b21a6b4b1f3cfe8dd11 /commands | |
parent | 09c88e84d196e6c0943b220cd6526d3473c530b6 (diff) |
commands: Fix broken commandeer
Diffstat (limited to 'commands')
-rw-r--r-- | commands/commandeer.go | 17 | ||||
-rw-r--r-- | commands/hugo.go | 15 |
2 files changed, 25 insertions, 7 deletions
diff --git a/commands/commandeer.go b/commands/commandeer.go index 19eadda10..7f7e20f7b 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -39,9 +39,22 @@ func (c *commandeer) PathSpec() *helpers.PathSpec { return c.pathSpec } +func (c *commandeer) initFs(fs *hugofs.Fs) error { + c.DepsCfg.Fs = fs + ps, err := helpers.NewPathSpec(fs, c.Cfg) + if err != nil { + return err + } + c.pathSpec = ps + return nil +} + func newCommandeer(cfg *deps.DepsCfg) (*commandeer, error) { - fs := hugofs.NewDefault(cfg.Language) - ps, err := helpers.NewPathSpec(fs, cfg.Cfg) + l := cfg.Language + if l == nil { + l = helpers.NewDefaultLanguage(cfg.Cfg) + } + ps, err := helpers.NewPathSpec(cfg.Fs, l) if err != nil { return nil, err } diff --git a/commands/hugo.go b/commands/hugo.go index de5798df9..5a056996d 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -18,6 +18,9 @@ package commands import ( "fmt" "io/ioutil" + + "github.com/spf13/hugo/hugofs" + "log" "net/http" "os" @@ -28,7 +31,6 @@ import ( "time" "github.com/spf13/hugo/config" - "github.com/spf13/hugo/hugofs" "github.com/spf13/hugo/parser" flag "github.com/spf13/pflag" @@ -288,6 +290,7 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { return cfg, err } + // Init file systems. This may be changed at a later point. cfg.Cfg = config c, err := newCommandeer(cfg) @@ -343,13 +346,13 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { } config.Set("workingDir", dir) - cfg.Fs = hugofs.NewFrom(osFs, config) + fs := hugofs.NewFrom(osFs, config) // Hugo writes the output to memory instead of the disk. // This is only used for benchmark testing. Cause the content is only visible // in memory. if renderToMemory { - c.Fs.Destination = new(afero.MemMapFs) + fs.Destination = new(afero.MemMapFs) // Rendering to memoryFS, publish to Root regardless of publishDir. c.Set("publishDir", "/") } @@ -371,16 +374,18 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] { cacheDir = cacheDir + helpers.FilePathSeparator } - isDir, err := helpers.DirExists(cacheDir, cfg.Fs.Source) + isDir, err := helpers.DirExists(cacheDir, fs.Source) utils.CheckErr(cfg.Logger, err) if !isDir { mkdir(cacheDir) } config.Set("cacheDir", cacheDir) } else { - config.Set("cacheDir", helpers.GetTempDir("hugo_cache", cfg.Fs.Source)) + config.Set("cacheDir", helpers.GetTempDir("hugo_cache", fs.Source)) } + c.initFs(fs) + cfg.Logger.INFO.Println("Using config file:", viper.ConfigFileUsed()) themeDir := c.PathSpec().GetThemeDir() |