summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorAndreas Deininger <adeininger@urbanonline.de>2023-06-27 16:33:28 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2023-06-28 16:20:54 +0200
commit635cc346cef6c6c7ada4dd1010a631613568d51d (patch)
tree90237d5a0372e7851f2088c9b5c90ae1e3fe1943 /commands
parent12646750aa186cf3bf50266f8eddf9cfebc3c9c9 (diff)
commands: Fix panic when running hugo new theme without theme name
Closes #11162.
Diffstat (limited to 'commands')
-rw-r--r--commands/new.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/commands/new.go b/commands/new.go
index a16453d62..9fbd9bf6e 100644
--- a/commands/new.go
+++ b/commands/new.go
@@ -56,7 +56,7 @@ If archetypes are provided in your theme or site, they will be used.
Ensure you run this within the root directory of your site.`,
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
if len(args) < 1 {
- return errors.New("path needs to be provided")
+ return newUserError("path needs to be provided")
}
h, err := r.Hugo(flagsToCfg(cd, nil))
if err != nil {
@@ -82,7 +82,7 @@ The new site will have the correct structure, but no content or theme yet.
Use ` + "`hugo new [contentPath]`" + ` to create new content.`,
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
if len(args) < 1 {
- return errors.New("path needs to be provided")
+ return newUserError("path needs to be provided")
}
createpath, err := filepath.Abs(filepath.Clean(args[0]))
if err != nil {
@@ -162,6 +162,9 @@ New theme is a skeleton. Please add content to the touched files. Add your
name to the copyright line in the license and adjust the theme.toml file
according to your needs.`,
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
+ if len(args) < 1 {
+ return newUserError("theme name needs to be provided")
+ }
h, err := r.Hugo(flagsToCfg(cd, nil))
if err != nil {
return err