Skip to content

Commit

Permalink
commands: Do not fail server build when /static is missing
Browse files Browse the repository at this point in the history
This was a un-intended change in Hugo 0.42. Most sites will have a static directory so this should not be a big issue, but this commit will revert back to old behaviour.

Fixes #4846
  • Loading branch information
bep committed Jun 13, 2018
1 parent 0f1fc01 commit 34ee27a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 0 additions & 5 deletions commands/commands_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,6 @@ Single: {{ .Title }}
List: {{ .Title }}
`)

writeFile(t, filepath.Join(d, "static", "my.txt"), `
MyMy
`)

return d, nil
Expand Down
5 changes: 4 additions & 1 deletion commands/hugo.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ func (c *commandeer) fullBuild() error {
copyStaticFunc := func() error {
cnt, err := c.copyStatic()
if err != nil {
return fmt.Errorf("Error copying static files: %s", err)
if !os.IsNotExist(err) {
return fmt.Errorf("Error copying static files: %s", err)
}
c.Logger.WARN.Println("No Static directory found")
}
langCount = cnt
langCount = cnt
Expand Down

1 comment on commit 34ee27a

@RealOrangeOne
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I spent last night trying to debug this in a theme, was going to raise it this morning. Glad to see there's a fix already!

Please sign in to comment.