summaryrefslogtreecommitdiffstats
path: root/commands/new.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-05 10:20:06 +0700
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-02-17 17:15:26 +0100
commit93ca7c9e958e34469a337e4efcc7c75774ec50fd (patch)
tree5dfa296cfe74fd5ef8f0d41ea4078704f453aa04 /commands/new.go
parente34af6ee30f70f5780a281e2fd8f4ed9b487ee61 (diff)
all: Refactor to nonglobal Viper, i18n etc.
This is a final rewrite that removes all the global state in Hugo, which also enables the use if `t.Parallel` in tests. Updates #2701 Fixes #3016
Diffstat (limited to 'commands/new.go')
-rw-r--r--commands/new.go19
1 files changed, 11 insertions, 8 deletions
diff --git a/commands/new.go b/commands/new.go
index b4a2740f3..a54ad5d2c 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -93,12 +93,14 @@ func NewContent(cmd *cobra.Command, args []string) error {
return err
}
- if flagChanged(cmd.Flags(), "format") {
- viper.Set("metaDataFormat", configFormat)
+ c := newCommandeer(cfg)
+
+ if c.flagChanged(cmd.Flags(), "format") {
+ c.Set("metaDataFormat", configFormat)
}
- if flagChanged(cmd.Flags(), "editor") {
- viper.Set("newContentEditor", contentEditor)
+ if c.flagChanged(cmd.Flags(), "editor") {
+ c.Set("newContentEditor", contentEditor)
}
if len(args) < 1 {
@@ -115,7 +117,7 @@ func NewContent(cmd *cobra.Command, args []string) error {
kind = contentType
}
- s, err := hugolib.NewSite(cfg)
+ s, err := hugolib.NewSite(*cfg)
if err != nil {
return newSystemError(err)
@@ -203,7 +205,7 @@ func NewSite(cmd *cobra.Command, args []string) error {
forceNew, _ := cmd.Flags().GetBool("force")
- return doNewSite(hugofs.NewDefault(), createpath, forceNew)
+ return doNewSite(hugofs.NewDefault(viper.New()), createpath, forceNew)
}
// NewTheme creates a new Hugo theme.
@@ -215,11 +217,12 @@ func NewTheme(cmd *cobra.Command, args []string) error {
}
if len(args) < 1 {
-
return newUserError("theme name needs to be provided")
}
- createpath := helpers.AbsPathify(filepath.Join(viper.GetString("themesDir"), args[0]))
+ c := newCommandeer(cfg)
+
+ createpath := c.PathSpec().AbsPathify(filepath.Join(c.Cfg.GetString("themesDir"), args[0]))
jww.INFO.Println("creating theme at", createpath)
if x, _ := helpers.Exists(createpath, cfg.Fs.Source); x {