diff options
author | Bjørn Erik Pedersen <[email protected]> | 2017-03-25 14:37:04 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2017-03-27 15:43:56 +0200 |
commit | 15b64d51da48807c5f896f17b33d8c0d054c9461 (patch) | |
tree | b8f585ad5a1741b26540184ec29ec2a26fc4060f /commands | |
parent | 148fedd227b8f4f5af8f72cb6841653140f82dfe (diff) | |
download | hugo-15b64d51da48807c5f896f17b33d8c0d054c9461.tar.gz hugo-15b64d51da48807c5f896f17b33d8c0d054c9461.zip |
all: Propagate baseURL error to the callers
Diffstat (limited to 'commands')
-rw-r--r-- | commands/benchmark.go | 5 | ||||
-rw-r--r-- | commands/commandeer.go | 13 | ||||
-rw-r--r-- | commands/hugo.go | 10 | ||||
-rw-r--r-- | commands/list.go | 15 | ||||
-rw-r--r-- | commands/new.go | 10 | ||||
-rw-r--r-- | commands/server.go | 5 |
6 files changed, 44 insertions, 14 deletions
diff --git a/commands/benchmark.go b/commands/benchmark.go index 4f9ab828b..6c42992a0 100644 --- a/commands/benchmark.go +++ b/commands/benchmark.go @@ -54,7 +54,10 @@ func benchmark(cmd *cobra.Command, args []string) error { return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } var memProf *os.File if memProfileFile != "" { diff --git a/commands/commandeer.go b/commands/commandeer.go index e7fd70651..19eadda10 100644 --- a/commands/commandeer.go +++ b/commands/commandeer.go @@ -16,6 +16,7 @@ package commands import ( "github.com/spf13/hugo/deps" "github.com/spf13/hugo/helpers" + "github.com/spf13/hugo/hugofs" ) type commandeer struct { @@ -35,12 +36,14 @@ func (c *commandeer) Set(key string, value interface{}) { // be configured before it is created. func (c *commandeer) PathSpec() *helpers.PathSpec { c.configured = true - if c.pathSpec == nil { - c.pathSpec = helpers.NewPathSpec(c.Fs, c.Cfg) - } return c.pathSpec } -func newCommandeer(cfg *deps.DepsCfg) *commandeer { - return &commandeer{DepsCfg: cfg} +func newCommandeer(cfg *deps.DepsCfg) (*commandeer, error) { + fs := hugofs.NewDefault(cfg.Language) + ps, err := helpers.NewPathSpec(fs, cfg.Cfg) + if err != nil { + return nil, err + } + return &commandeer{DepsCfg: cfg, pathSpec: ps}, nil } diff --git a/commands/hugo.go b/commands/hugo.go index 48d4e0dc1..de5798df9 100644 --- a/commands/hugo.go +++ b/commands/hugo.go @@ -118,7 +118,10 @@ Complete documentation is available at http://gohugo.io/.`, return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } if buildWatch { cfg.Cfg.Set("disableLiveReload", true) @@ -287,7 +290,10 @@ func InitializeConfig(subCmdVs ...*cobra.Command) (*deps.DepsCfg, error) { cfg.Cfg = config - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return nil, err + } for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) { c.initializeFlags(cmdV) diff --git a/commands/list.go b/commands/list.go index 3f3286f38..97753cc88 100644 --- a/commands/list.go +++ b/commands/list.go @@ -49,7 +49,10 @@ var listDraftsCmd = &cobra.Command{ return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } c.Set("buildDrafts", true) @@ -87,7 +90,10 @@ posted in the future.`, return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } c.Set("buildFuture", true) @@ -125,7 +131,10 @@ expired.`, return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } c.Set("buildExpired", true) diff --git a/commands/new.go b/commands/new.go index e2472af0c..abb234b87 100644 --- a/commands/new.go +++ b/commands/new.go @@ -93,7 +93,10 @@ func NewContent(cmd *cobra.Command, args []string) error { return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } if flagChanged(cmd.Flags(), "format") { c.Set("metaDataFormat", configFormat) @@ -220,7 +223,10 @@ func NewTheme(cmd *cobra.Command, args []string) error { return newUserError("theme name needs to be provided") } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } createpath := c.PathSpec().AbsPathify(filepath.Join(c.Cfg.GetString("themesDir"), args[0])) jww.INFO.Println("creating theme at", createpath) diff --git a/commands/server.go b/commands/server.go index 3e7673773..ae51d075d 100644 --- a/commands/server.go +++ b/commands/server.go @@ -106,7 +106,10 @@ func server(cmd *cobra.Command, args []string) error { return err } - c := newCommandeer(cfg) + c, err := newCommandeer(cfg) + if err != nil { + return err + } if flagChanged(cmd.Flags(), "disableLiveReload") { c.Set("disableLiveReload", disableLiveReload) |