Don't create the public folder unless needed - hugo - [fork] hugo port for 9front
(HTM) git clone git@git.drkhsh.at/hugo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
(DIR) commit e96cdfe9664cb38c3e16cc00cc630cf6f258d547
(DIR) parent ffdbce5787a45e8537b7a77515ca06e4deee2504
(HTM) Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Sun, 28 May 2023 10:07:03 +0200
Don't create the public folder unless needed
Fixes #11031
Diffstat:
M hugofs/fs.go | 6 +-----
M main_test.go | 5 +++++
M testscripts/commands/hugo__noconfi… | 8 ++++++--
3 files changed, 12 insertions(+), 7 deletions(-)
---
(DIR) diff --git a/hugofs/fs.go b/hugofs/fs.go
@@ -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{
(DIR) diff --git a/main_test.go b/main_test.go
@@ -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())
}
(DIR) diff --git a/testscripts/commands/hugo__noconfig.txt b/testscripts/commands/hugo__noconfig.txt
@@ -1,4 +1,8 @@
+mkdir mysite
+cd mysite
! hugo
-stderr 'Unable to locate config file or config directory'
-\ No newline at end of file
+stderr 'Unable to locate config file or config directory'
+ls .
+stdout 'Empty dir'
+\ No newline at end of file