all repos — website @ a4e0ebceb8e664bf3f6e3dc36df0120a9ea9803e

My website

build: use same dir for static/rendered output
Alan Pearce alan@alanpearce.eu
Fri, 19 Apr 2024 14:47:47 +0200
commit

a4e0ebceb8e664bf3f6e3dc36df0120a9ea9803e

parent

731d1c63dca1c8bf6d99e9c0f316f59595861ac8

1 files changed, 5 insertions(+), 5 deletions(-)

jump to
M cmd/build/build.gocmd/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")