all repos — homestead @ e1b72de1e3567b02f9c7b68ad0523cadfc968e93

Code for my website

copy static files directly in go

Alan Pearce
commit

e1b72de1e3567b02f9c7b68ad0523cadfc968e93

parent

7908475ecfeeb896d2283f9e2a2dd0c3ec820808

1 file changed, 10 insertions(+), 0 deletions(-)

changed files
M cmd/build/build.gocmd/build/build.go
@@ -26,6 +26,7 @@ "github.com/adrg/frontmatter"
"github.com/antchfx/xmlquery" "github.com/antchfx/xpath" mapset "github.com/deckarep/golang-set/v2" + cp "github.com/otiai10/copy" "github.com/pkg/errors" "github.com/yuin/goldmark" "github.com/yuin/goldmark/extension"
@@ -527,6 +528,15 @@ slog.Debug("starting build process")
_, err := os.Getwd() if err != nil { log.Panic(errors.Errorf("working directory does not exist: %v", err)) + } + + 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{}) + if err != nil { + log.Panic(errors.Errorf("could not copy static files: %v", err)) } if err := build(); err != nil {