Don't create the public folder unless needed

Fixes #11031
This commit is contained in:
Bjørn Erik Pedersen 2023-05-28 10:07:03 +02:00
parent ffdbce5787
commit e96cdfe966
3 changed files with 11 additions and 6 deletions

View file

@ -116,13 +116,9 @@ func newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs {
panic("workingDir is too short") panic("workingDir is too short")
} }
// If this does not exist, it will be created later.
absPublishDir := paths.AbsPathify(workingDir, publishDir) 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) pubFs := afero.NewBasePathFs(destination, absPublishDir)
return &Fs{ return &Fs{

View file

@ -132,6 +132,11 @@ var commonTestScriptsParam = testscript.Params{
if err != nil { if err != nil {
ts.Fatalf("%v", err) ts.Fatalf("%v", err)
} }
if len(fis) == 0 {
// To simplify empty dir checks.
fmt.Fprintln(ts.Stdout(), "Empty dir")
return
}
for _, fi := range fis { 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()) fmt.Fprintf(ts.Stdout(), "%s %04o %s %s\n", fi.Mode(), fi.Mode().Perm(), fi.ModTime().Format(time.RFC3339Nano), fi.Name())
} }

View file

@ -1,4 +1,8 @@
mkdir mysite
cd mysite
! hugo ! hugo
stderr 'Unable to locate config file or config directory' stderr 'Unable to locate config file or config directory'
ls .
stdout 'Empty dir'