Skip to content

Commit

Permalink
Make sure resources directory isn't created in hugo new theme
Browse files Browse the repository at this point in the history
Fixes #11382
  • Loading branch information
bep committed Aug 23, 2023
1 parent 24b1be4 commit ebaa733
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
12 changes: 7 additions & 5 deletions commands/new.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"strings"

"github.com/bep/simplecobra"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/config"
"github.com/gohugoio/hugo/create"
"github.com/gohugoio/hugo/create/skeletons"
Expand Down Expand Up @@ -120,14 +121,15 @@ according to your needs.`,
if len(args) < 1 {
return newUserError("theme name needs to be provided")
}
h, err := r.Hugo(flagsToCfg(cd, nil))
cfg := config.New()
cfg.Set("publishDir", "public")

conf, err := r.ConfigFromProvider(r.configVersionID.Load(), flagsToCfg(cd, cfg))
if err != nil {
return err
}
ps := h.PathSpec
sourceFs := ps.Fs.Source
themesDir := h.Configs.LoadingInfo.BaseConfig.ThemesDir
createpath := ps.AbsPathify(filepath.Join(themesDir, args[0]))
sourceFs := conf.fs.Source
createpath := paths.AbsPathify(conf.configs.Base.WorkingDir, filepath.Join(conf.configs.Base.ThemesDir, args[0]))
r.Println("Creating new theme in", createpath)

err = skeletons.CreateTheme(createpath, sourceFs)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ exists i18n
exists layouts
exists static
exists themes
! exists resources

hugo new theme -h
stdout 'Create a new theme \(skeleton\) called \[name\] in ./themes'
hugo new theme mytheme
stdout 'Creating new theme'
! exists resources
cd themes
cd mytheme
checkfile archetypes/default.md
Expand Down

0 comments on commit ebaa733

Please sign in to comment.