Skip to content

Commit

Permalink
Don't create the public folder unless needed
Browse files Browse the repository at this point in the history
Fixes #11031
  • Loading branch information
bep committed May 28, 2023
1 parent ffdbce5 commit e96cdfe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
6 changes: 1 addition & 5 deletions hugofs/fs.go
Expand Up @@ -116,13 +116,9 @@ func newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs {
panic("workingDir is too short")
}

// If this does not exist, it will be created later.
absPublishDir := paths.AbsPathify(workingDir, publishDir)

// Make sure we always have the /public folder ready to use.
if err := source.MkdirAll(absPublishDir, 0777); err != nil && !os.IsExist(err) {
panic(err)
}

pubFs := afero.NewBasePathFs(destination, absPublishDir)

return &Fs{
Expand Down
5 changes: 5 additions & 0 deletions main_test.go
Expand Up @@ -132,6 +132,11 @@ var commonTestScriptsParam = testscript.Params{
if err != nil {
ts.Fatalf("%v", err)
}
if len(fis) == 0 {
// To simplify empty dir checks.
fmt.Fprintln(ts.Stdout(), "Empty dir")
return
}
for _, fi := range fis {
fmt.Fprintf(ts.Stdout(), "%s %04o %s %s\n", fi.Mode(), fi.Mode().Perm(), fi.ModTime().Format(time.RFC3339Nano), fi.Name())
}
Expand Down
6 changes: 5 additions & 1 deletion testscripts/commands/hugo__noconfig.txt
@@ -1,4 +1,8 @@

mkdir mysite
cd mysite
! hugo

stderr 'Unable to locate config file or config directory'
stderr 'Unable to locate config file or config directory'
ls .
stdout 'Empty dir'

0 comments on commit e96cdfe

Please sign in to comment.