diff options
author | Eddy Pedroni <eddy@0xf7.com> | 2020-02-03 22:26:00 +0100 |
---|---|---|
committer | Eddy Pedroni <eddy@0xf7.com> | 2020-02-03 22:26:00 +0100 |
commit | e838cf94aa507f6a3ea93c65451b902cc1085b34 (patch) | |
tree | 08bd8856e9c328d9cf8fea0c7209ed98746c7424 | |
parent | 633a882544d3b54cc7b7cfc96359a2ca1497d766 (diff) |
Added cleanup, basic specs are implemented
-rw-r--r-- | main.go | 18 | ||||
-rw-r--r-- | page.go | 1 |
2 files changed, 18 insertions, 1 deletions
@@ -19,6 +19,7 @@ func main() { // create temporary target directory tmp := createTempDir("godocs") + defer os.RemoveAll(tmp) // gather all sites in docsRoot sites := getSites(cfg) @@ -42,4 +43,21 @@ func main() { if err != nil { panic(err) } + + // if we are here, generation succeeded, so we move the generated content to the target directory + err = os.RemoveAll(cfg.TargetDir) + if err != nil { + panic(err) + } + + err = os.Rename(tmp, cfg.TargetDir) + if err != nil { + panic(err) + } + + // fix because for some reason the generated directory ends up with the wrong permissions + err = os.Chmod(cfg.TargetDir, 0755) + if err != nil { + panic(err) + } } @@ -55,7 +55,6 @@ func createPageMap(site *siteData, entries []Renderer) { if err != nil { panic(err) } - } // create landing page |