From 88e5a55c838a28c36573ad523e4bcf3ff51355f8 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 18 Apr 2024 17:37:07 +0200 Subject: copy static files directly in go --- cmd/build/build.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'cmd') diff --git a/cmd/build/build.go b/cmd/build/build.go index 4254bf8..5007ead 100644 --- a/cmd/build/build.go +++ b/cmd/build/build.go @@ -26,6 +26,7 @@ import ( "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" @@ -529,6 +530,15 @@ func main() { 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 { switch cause := errors.Cause(err).(type) { case *fs.PathError: -- cgit 1.4.1