From 05fe19526630e6df5f5f90c7f8569568b895db31 Mon Sep 17 00:00:00 2001 From: Kirill Zhuravlev Date: Sat, 4 Feb 2023 03:01:22 +0100 Subject: [PATCH] cleanup output dir at start --- main.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 5c0bf81a..2994681d 100644 --- a/main.go +++ b/main.go @@ -45,8 +45,18 @@ var outIndexFile = filepath.Join(outDir, "index.html") var outSitemapFile = filepath.Join(outDir, "sitemap.xml") func main() { - outIndexAbs := filepath.Join(outDir, outIndexFile) - err := GenerateHTML(readmePath, outIndexAbs) + // Cleanup and re-create output directory + { + if err := os.RemoveAll(outDir); err != nil { + panic(err) + } + + if err := mkdirAll(outDir); err != nil { + panic(err) + } + } + + err := GenerateHTML(readmePath, outIndexFile) if err != nil { panic(err) }