Skip to content

Commit 635cc34

Browse files
deiningbep
authored andcommitted
commands: Fix panic when running hugo new theme without theme name
Closes #11162.
1 parent 1264675 commit 635cc34

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: commands/new.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ If archetypes are provided in your theme or site, they will be used.
5656
Ensure you run this within the root directory of your site.`,
5757
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
5858
if len(args) < 1 {
59-
return errors.New("path needs to be provided")
59+
return newUserError("path needs to be provided")
6060
}
6161
h, err := r.Hugo(flagsToCfg(cd, nil))
6262
if err != nil {
@@ -82,7 +82,7 @@ The new site will have the correct structure, but no content or theme yet.
8282
Use ` + "`hugo new [contentPath]`" + ` to create new content.`,
8383
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
8484
if len(args) < 1 {
85-
return errors.New("path needs to be provided")
85+
return newUserError("path needs to be provided")
8686
}
8787
createpath, err := filepath.Abs(filepath.Clean(args[0]))
8888
if err != nil {
@@ -162,6 +162,9 @@ New theme is a skeleton. Please add content to the touched files. Add your
162162
name to the copyright line in the license and adjust the theme.toml file
163163
according to your needs.`,
164164
run: func(ctx context.Context, cd *simplecobra.Commandeer, r *rootCommand, args []string) error {
165+
if len(args) < 1 {
166+
return newUserError("theme name needs to be provided")
167+
}
165168
h, err := r.Hugo(flagsToCfg(cd, nil))
166169
if err != nil {
167170
return err

0 commit comments

Comments
 (0)