Skip to content

Commit e96cdfe

Browse files
committedMay 28, 2023
Don't create the public folder unless needed
Fixes #11031
1 parent ffdbce5 commit e96cdfe

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed
 

‎hugofs/fs.go

+1-5
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,9 @@ func newFs(source, destination afero.Fs, workingDir, publishDir string) *Fs {
116116
panic("workingDir is too short")
117117
}
118118

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

121-
// Make sure we always have the /public folder ready to use.
122-
if err := source.MkdirAll(absPublishDir, 0777); err != nil && !os.IsExist(err) {
123-
panic(err)
124-
}
125-
126122
pubFs := afero.NewBasePathFs(destination, absPublishDir)
127123

128124
return &Fs{

‎main_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ var commonTestScriptsParam = testscript.Params{
132132
if err != nil {
133133
ts.Fatalf("%v", err)
134134
}
135+
if len(fis) == 0 {
136+
// To simplify empty dir checks.
137+
fmt.Fprintln(ts.Stdout(), "Empty dir")
138+
return
139+
}
135140
for _, fi := range fis {
136141
fmt.Fprintf(ts.Stdout(), "%s %04o %s %s\n", fi.Mode(), fi.Mode().Perm(), fi.ModTime().Format(time.RFC3339Nano), fi.Name())
137142
}
+5-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11

2+
mkdir mysite
3+
cd mysite
24
! hugo
35

4-
stderr 'Unable to locate config file or config directory'
6+
stderr 'Unable to locate config file or config directory'
7+
ls .
8+
stdout 'Empty dir'

0 commit comments

Comments
 (0)
Please sign in to comment.