build: use same dir for static/rendered output
Alan Pearce alan@alanpearce.eu
Fri, 19 Apr 2024 14:47:47 +0200
1 files changed, 5 insertions(+), 5 deletions(-)
jump to
M cmd/build/build.go → cmd/build/build.go
@@ -402,12 +402,11 @@ } return nil } -func build() error { +func build(outDir string) error { config, err := config.GetConfig() if err != nil { return err } - outDir := "public" if err := mkdirp(outDir, "post"); err != nil { return errors.WithMessage(err, "could not create post output directory") } @@ -530,18 +529,19 @@ if err != nil { log.Panic(errors.Errorf("working directory does not exist: %v", err)) } + outDir := "public" err = os.RemoveAll("public") if err != nil { log.Panic(errors.Errorf("could not remove public directory: %v", err)) } - err = cp.Copy("static", "public", cp.Options{ - PreserveTimes: true, + err = cp.Copy("static", outDir, cp.Options{ + PreserveTimes: true, }) if err != nil { log.Panic(errors.Errorf("could not copy static files: %v", err)) } - if err := build(); err != nil { + if err := build(outDir); err != nil { switch cause := errors.Cause(err).(type) { case *fs.PathError: slog.Info("pathError")