commands: Do not fail server build when /static is missing
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 13 Jun 2018 06:48:20 +0000 (08:48 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 13 Jun 2018 06:48:20 +0000 (08:48 +0200)
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

commands/commands_test.go
commands/hugo.go

index d576b44288bcd6c1e7a181c2d0a7cfe60e941201..907f003c0bde72d5a2a9ad1fb7994391f6400dac 100644 (file)
@@ -235,11 +235,6 @@ Single: {{ .Title }}
 
 List: {{ .Title }}
 
-`)
-
-       writeFile(t, filepath.Join(d, "static", "my.txt"), `
-MyMy
-
 `)
 
        return d, nil
index c4fee122d4a40a02780f4f204075c77294d93939..5c87bd96e3e31a470bcb49c0b47eaa6c8e3a31e4 100644 (file)
@@ -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