diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-01-02 13:54:28 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-01-02 13:54:28 -0800 |
commit | af3f7ada295115808c2407e1576ec703091c6c0a (patch) | |
tree | fc8dcb556d4a61bc44665895f0a01ff8f8d1460e /cmd/ponzu/options.go | |
parent | ae201cf1af12132ed5aed3c180bcb785dee85621 (diff) |
more code cleanup and adding content dir empty on build before copy
Diffstat (limited to 'cmd/ponzu/options.go')
-rw-r--r-- | cmd/ponzu/options.go | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 1316a67..4d102c5 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -150,13 +150,6 @@ func vendorCorePackages(path string) error { return err } - // // create a user content directory to be vendored - // contentPath := filepath.Join(path, "content") - // err = os.Mkdir(contentPath, os.ModeDir|os.ModePerm) - // if err != nil { - // return err - // } - dirs := []string{"content", "management", "system"} for _, dir := range dirs { err = os.Rename(filepath.Join(path, dir), filepath.Join(vendorPath, dir)) @@ -247,6 +240,27 @@ func copyFilesWarnConflicts(srcDir, dstDir string, conflicts []string) error { return nil } +func emptyDir(path string) error { + d, err := os.Open(path) + if err != nil { + return err + } + defer d.Close() + + names, err := d.Readdirnames(-1) + if err != nil { + return err + } + for _, name := range names { + err = os.RemoveAll(filepath.Join(path, name)) + if err != nil { + return err + } + } + + return nil +} + func buildPonzuServer(args []string) error { pwd, err := os.Getwd() if err != nil { @@ -256,7 +270,10 @@ func buildPonzuServer(args []string) error { // copy all ./content files to internal vendor directory src := "content" dst := filepath.Join("cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "content") - + err = emptyDir(dst) + if err != nil { + return err + } err = copyFilesWarnConflicts(src, dst, []string{"doc.go"}) if err != nil { return err @@ -278,9 +295,7 @@ func buildPonzuServer(args []string) error { p := filepath.Join(pwd, "cmd", "ponzu", file) cmdBuildFilePaths = append(cmdBuildFilePaths, p) } - // mainPath := filepath.Join(pwd, "cmd", "ponzu", "main.go") - // optsPath := filepath.Join(pwd, "cmd", "ponzu", "options.go") - // genPath := filepath.Join(pwd, "cmd", "ponzu", "generate.go") + build := exec.Command(gocmd, append(buildOptions, cmdBuildFilePaths...)...) build.Stderr = os.Stderr build.Stdout = os.Stdout |