]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Make sure resources directory isn't created in hugo new theme
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 23 Aug 2023 19:53:46 +0000 (21:53 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 23 Aug 2023 20:50:35 +0000 (22:50 +0200)
Fixes #11382

commands/new.go
testscripts/commands/new.txt [deleted file]
testscripts/commands/noop.txt [new file with mode: 0644]
testscripts/unfinished/new.txt [new file with mode: 0644]
testscripts/unfinished/noop.txt [deleted file]

index 3f43a687f47eb066e60bff10b3950fd115c6d94e..ffd75b2bbb4249a7f6f288c864bc2f49af5f175b 100644 (file)
@@ -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"
@@ -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)
diff --git a/testscripts/commands/new.txt b/testscripts/commands/new.txt
deleted file mode 100644 (file)
index f44aaca..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-# Test the new command.
-
-hugo new site -h
-stdout 'Create a new site in the provided directory'
-hugo new site my-yaml-site --format yml
-checkfile my-yaml-site/hugo.yml
-hugo new site mysite -f
-stdout 'Congratulations! Your new Hugo site was created in'
-cd mysite
-checkfile archetypes/default.md
-checkfile hugo.toml
-exists assets
-exists content
-exists data
-exists i18n
-exists layouts
-exists static
-exists themes
-
-hugo new theme -h
-stdout 'Create a new theme \(skeleton\) called \[name\] in ./themes'
-hugo new theme mytheme
-stdout 'Creating new theme'
-cd themes
-cd mytheme
-checkfile archetypes/default.md
-checkfile assets/css/main.css
-checkfile assets/js/main.js
-checkfile content/_index.md
-checkfile content/posts/_index.md
-checkfile content/posts/post-1.md
-checkfile content/posts/post-2.md
-checkfile content/posts/post-3/bryce-canyon.jpg
-checkfile content/posts/post-3/index.md
-checkfile layouts/_default/baseof.html
-checkfile layouts/_default/home.html
-checkfile layouts/_default/list.html
-checkfile layouts/_default/single.html
-checkfile layouts/partials/footer.html
-checkfile layouts/partials/head.html
-checkfile layouts/partials/head/css.html
-checkfile layouts/partials/head/js.html
-checkfile layouts/partials/header.html
-checkfile layouts/partials/menu.html
-checkfile layouts/partials/terms.html
-checkfile static/favicon.ico
-checkfile LICENSE
-checkfile README.md
-checkfile hugo.toml
-checkfile theme.toml
-exists data
-exists i18n
-
-cd $WORK/mysite
-
-hugo new -h
-stdout 'Create a new content file.'
-hugo new posts/my-first-post.md
-checkfile content/posts/my-first-post.md
-
-cd ..
-cd myexistingsite
-hugo new post/foo.md -t mytheme
-grep 'Dummy content' content/post/foo.md
-
--- myexistingsite/hugo.toml --
-theme = "mytheme"
--- myexistingsite/content/p1.md --
----
-title: "P1"
----
--- myexistingsite/themes/mytheme/hugo.toml --
--- myexistingsite/themes/mytheme/archetypes/post.md --
----
-title: "{{ replace .Name "-" " " | title }}"
-date: {{ .Date }}
-draft: true
----
-
-Dummy content.
diff --git a/testscripts/commands/noop.txt b/testscripts/commands/noop.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testscripts/unfinished/new.txt b/testscripts/unfinished/new.txt
new file mode 100644 (file)
index 0000000..4ac264e
--- /dev/null
@@ -0,0 +1,82 @@
+# Test the new command.
+
+hugo new site -h
+stdout 'Create a new site in the provided directory'
+hugo new site my-yaml-site --format yml
+checkfile my-yaml-site/hugo.yml
+hugo new site mysite -f
+stdout 'Congratulations! Your new Hugo site was created in'
+cd mysite
+checkfile archetypes/default.md
+checkfile hugo.toml
+exists assets
+exists content
+exists data
+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
+checkfile assets/css/main.css
+checkfile assets/js/main.js
+checkfile content/_index.md
+checkfile content/posts/_index.md
+checkfile content/posts/post-1.md
+checkfile content/posts/post-2.md
+checkfile content/posts/post-3/bryce-canyon.jpg
+checkfile content/posts/post-3/index.md
+checkfile layouts/_default/baseof.html
+checkfile layouts/_default/home.html
+checkfile layouts/_default/list.html
+checkfile layouts/_default/single.html
+checkfile layouts/partials/footer.html
+checkfile layouts/partials/head.html
+checkfile layouts/partials/head/css.html
+checkfile layouts/partials/head/js.html
+checkfile layouts/partials/header.html
+checkfile layouts/partials/menu.html
+checkfile layouts/partials/terms.html
+checkfile static/favicon.ico
+checkfile LICENSE
+checkfile README.md
+checkfile hugo.toml
+checkfile theme.toml
+exists data
+exists i18n
+
+cd $WORK/mysite
+
+hugo new -h
+stdout 'Create a new content file.'
+hugo new posts/my-first-post.md
+checkfile content/posts/my-first-post.md
+
+cd ..
+cd myexistingsite
+hugo new post/foo.md -t mytheme
+grep 'Dummy content' content/post/foo.md
+
+-- myexistingsite/hugo.toml --
+theme = "mytheme"
+-- myexistingsite/content/p1.md --
+---
+title: "P1"
+---
+-- myexistingsite/themes/mytheme/hugo.toml --
+-- myexistingsite/themes/mytheme/archetypes/post.md --
+---
+title: "{{ replace .Name "-" " " | title }}"
+date: {{ .Date }}
+draft: true
+---
+
+Dummy content.
diff --git a/testscripts/unfinished/noop.txt b/testscripts/unfinished/noop.txt
deleted file mode 100644 (file)
index e69de29..0000000