Skip to content

Commit

Permalink
Fix --renderStaticToDisk
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Mar 21, 2022
1 parent 4655ebc commit 77220ef
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
16 changes: 3 additions & 13 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
# with older Go versions, but the improvements in Go 1.18 were to good to pass on (e.g. break and continue).
# Note that you don't need Go (or Go 1.18) to run a pre-built binary.
go-version: [1.18.x]
os: [ubuntu-latest, macos-latest, windows-latest]
os: [windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand Down Expand Up @@ -72,15 +72,5 @@ jobs:
echo "$env:GITHUB_WORKSPACE/sass_embedded/" | Out-File -FilePath $Env:GITHUB_PATH -Encoding utf-8 -Append
- name: Test
run: |
mage -v test
mage -v check;
- name: Build Docs
env:
HUGO_BUILD_TAGS: extended
HUGO_TIMEOUT: 31000
HUGO_IGNOREERRORS: error-remote-getjson
HUGO_SERVICES_INSTAGRAM_ACCESSTOKEN: dummytoken
run: |
mage -v hugo
./hugo -s docs/
./hugo --renderToMemory -s docs/
go test -v -run TestServerFlags ./commands
15 changes: 14 additions & 1 deletion commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package commands
import (
"bytes"
"errors"
"fmt"
"io/ioutil"
"net"
"os"
Expand All @@ -42,6 +43,7 @@ import (
"github.com/spf13/afero"

"github.com/bep/debounce"
"github.com/bep/overlayfs"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
Expand Down Expand Up @@ -393,9 +395,20 @@ func (c *commandeer) loadConfig() error {
// Writes the dynamic output on memory,
// while serve others directly from publishDir
publishDir := config.GetString("publishDir")
fmt.Println("publishDir ===>", publishDir)
writableFs := afero.NewBasePathFs(afero.NewMemMapFs(), publishDir)
publicFs := afero.NewOsFs()
fs.Destination = afero.NewCopyOnWriteFs(afero.NewReadOnlyFs(publicFs), writableFs)

// TODO(bep) use this overlayfs in the other places.
fs.Destination = overlayfs.New(
overlayfs.Options{
FirstWritable: true,
Fss: []afero.Fs{
writableFs,
publicFs,
},
},
)
fs.DestinationStatic = publicFs
} else if createMemFs {
// Hugo writes the output to memory instead of the disk.
Expand Down
3 changes: 3 additions & 0 deletions commands/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ func TestServerFlags(t *testing.T) {
{"--renderToDisk", func(c *qt.C, r serverTestResult) {
assertPublic(c, r, true)
}},
{"--renderStaticToDisk", func(c *qt.C, r serverTestResult) {
assertPublic(c, r, true)
}},
} {
c.Run(test.flag, func(c *qt.C) {
config := `
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/bep/godartsass v0.14.0
github.com/bep/golibsass v1.0.0
github.com/bep/gowebp v0.1.0
github.com/bep/overlayfs v0.1.0
github.com/bep/tmc v0.5.1
github.com/clbanning/mxj/v2 v2.5.5
github.com/cli/safeexec v1.0.0
Expand Down Expand Up @@ -48,7 +49,7 @@ require (
github.com/russross/blackfriday v1.6.0
github.com/rwcarlsen/goexif v0.0.0-20190401172101-9e8deecbddbd
github.com/sanity-io/litter v1.5.2
github.com/spf13/afero v1.8.1
github.com/spf13/afero v1.8.2
github.com/spf13/cast v1.4.1
github.com/spf13/cobra v1.4.0
github.com/spf13/fsync v0.9.0
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ github.com/bep/golibsass v1.0.0 h1:gNguBMSDi5yZEZzVZP70YpuFQE3qogJIGUlrVILTmOw=
github.com/bep/golibsass v1.0.0/go.mod h1:DL87K8Un/+pWUS75ggYv41bliGiolxzDKWJAq3eJ1MA=
github.com/bep/gowebp v0.1.0 h1:4/iQpfnxHyXs3x/aTxMMdOpLEQQhFmF6G7EieWPTQyo=
github.com/bep/gowebp v0.1.0/go.mod h1:ZhFodwdiFp8ehGJpF4LdPl6unxZm9lLFjxD3z2h2AgI=
github.com/bep/overlayfs v0.1.0 h1:1hOCrvS4E5Hf0qwxM7m+9oitqClD9mRjQ1d4pECsVcU=
github.com/bep/overlayfs v0.1.0/go.mod h1:NFjSmn3kCqG7KX2Lmz8qT8VhPPCwZap3UNogXawoQHM=
github.com/bep/tmc v0.5.1 h1:CsQnSC6MsomH64gw0cT5f+EwQDcvZz4AazKunFwTpuI=
github.com/bep/tmc v0.5.1/go.mod h1:tGYHN8fS85aJPhDLgXETVKp+PR382OvFi2+q2GkGsq0=
github.com/bep/workers v1.0.0 h1:U+H8YmEaBCEaFZBst7GcRVEoqeRC9dzH2dWOwGmOchg=
Expand Down Expand Up @@ -413,6 +415,8 @@ github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasO
github.com/spf13/afero v1.2.2/go.mod h1:9ZxEEn6pIJ8Rxe320qSDBk6AsU0r9pR7Q4OcevTdifk=
github.com/spf13/afero v1.8.1 h1:izYHOT71f9iZ7iq37Uqjael60/vYC6vMtzedudZ0zEk=
github.com/spf13/afero v1.8.1/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/afero v1.8.2 h1:xehSyVa0YnHWsJ49JFljMpg1HX19V6NDZ1fkm1Xznbo=
github.com/spf13/afero v1.8.2/go.mod h1:CtAatgMJh6bJEIs48Ay/FOnkljP3WeGUG0MC1RfAqwo=
github.com/spf13/cast v1.4.1 h1:s0hze+J0196ZfEMTs80N7UlFt0BDuQ7Q+JDnHiMWKdA=
github.com/spf13/cast v1.4.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
github.com/spf13/cobra v1.4.0 h1:y+wJpx64xcgO1V+RcnwW0LEHxTKRi2ZDPSBjWnrg88Q=
Expand Down

0 comments on commit 77220ef

Please sign in to comment.