mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
commands: Fix broken commandeer
This commit is contained in:
parent
09c88e84d1
commit
ee4a33b14f
2 changed files with 25 additions and 7 deletions
|
@ -39,9 +39,22 @@ func (c *commandeer) PathSpec() *helpers.PathSpec {
|
||||||
return c.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) {
|
func newCommandeer(cfg *deps.DepsCfg) (*commandeer, error) {
|
||||||
fs := hugofs.NewDefault(cfg.Language)
|
l := cfg.Language
|
||||||
ps, err := helpers.NewPathSpec(fs, cfg.Cfg)
|
if l == nil {
|
||||||
|
l = helpers.NewDefaultLanguage(cfg.Cfg)
|
||||||
|
}
|
||||||
|
ps, err := helpers.NewPathSpec(cfg.Fs, l)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ package commands
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
|
||||||
|
"github.com/spf13/hugo/hugofs"
|
||||||
|
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
@ -28,7 +31,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/spf13/hugo/config"
|
"github.com/spf13/hugo/config"
|
||||||
"github.com/spf13/hugo/hugofs"
|
|
||||||
|
|
||||||
"github.com/spf13/hugo/parser"
|
"github.com/spf13/hugo/parser"
|
||||||
flag "github.com/spf13/pflag"
|
flag "github.com/spf13/pflag"
|
||||||
|
@ -288,6 +290,7 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) {
|
||||||
return cfg, err
|
return cfg, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Init file systems. This may be changed at a later point.
|
||||||
cfg.Cfg = config
|
cfg.Cfg = config
|
||||||
|
|
||||||
c, err := newCommandeer(cfg)
|
c, err := newCommandeer(cfg)
|
||||||
|
@ -343,13 +346,13 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) {
|
||||||
}
|
}
|
||||||
config.Set("workingDir", dir)
|
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.
|
// Hugo writes the output to memory instead of the disk.
|
||||||
// This is only used for benchmark testing. Cause the content is only visible
|
// This is only used for benchmark testing. Cause the content is only visible
|
||||||
// in memory.
|
// in memory.
|
||||||
if renderToMemory {
|
if renderToMemory {
|
||||||
c.Fs.Destination = new(afero.MemMapFs)
|
fs.Destination = new(afero.MemMapFs)
|
||||||
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
// Rendering to memoryFS, publish to Root regardless of publishDir.
|
||||||
c.Set("publishDir", "/")
|
c.Set("publishDir", "/")
|
||||||
}
|
}
|
||||||
|
@ -371,16 +374,18 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) {
|
||||||
if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
|
if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
|
||||||
cacheDir = cacheDir + helpers.FilePathSeparator
|
cacheDir = cacheDir + helpers.FilePathSeparator
|
||||||
}
|
}
|
||||||
isDir, err := helpers.DirExists(cacheDir, cfg.Fs.Source)
|
isDir, err := helpers.DirExists(cacheDir, fs.Source)
|
||||||
utils.CheckErr(cfg.Logger, err)
|
utils.CheckErr(cfg.Logger, err)
|
||||||
if !isDir {
|
if !isDir {
|
||||||
mkdir(cacheDir)
|
mkdir(cacheDir)
|
||||||
}
|
}
|
||||||
config.Set("cacheDir", cacheDir)
|
config.Set("cacheDir", cacheDir)
|
||||||
} else {
|
} 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())
|
cfg.Logger.INFO.Println("Using config file:", viper.ConfigFileUsed())
|
||||||
|
|
||||||
themeDir := c.PathSpec().GetThemeDir()
|
themeDir := c.PathSpec().GetThemeDir()
|
||||||
|
|
Loading…
Reference in a new issue