diff options
author | Steve Manuel <nilslice@gmail.com> | 2017-02-21 18:20:20 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2017-02-21 18:20:20 -0800 |
commit | 7d912abbd74761c9d20ffbfedd5fede5d4562d06 (patch) | |
tree | 734b2adcc6dfbaec068b63d03c500a52dd807f24 | |
parent | 3c7327058bd2ee890d36809fd171f1477e0ebfe5 (diff) |
adding new file to be included in build, new buildOutputPath function to determine exec path
-rw-r--r-- | cmd/ponzu/main.go | 7 | ||||
-rw-r--r-- | cmd/ponzu/options.go | 5 | ||||
-rw-r--r-- | cmd/ponzu/paths.go | 14 |
3 files changed, 23 insertions, 3 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index 6c52e01..0bb92d2 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -15,6 +15,8 @@ import ( "github.com/ponzu-cms/ponzu/system/db" "github.com/ponzu-cms/ponzu/system/tls" + "path/filepath" + _ "github.com/ponzu-cms/ponzu/content" ) @@ -146,7 +148,10 @@ func main() { services = "admin,api" } - serve := exec.Command(buildOutputName(), + path := buildOutputPath() + name := buildOutputName() + buildPathName := strings.Join([]string{path, name}, string(filepath.Separator)) + serve := exec.Command(buildPathName, fmt.Sprintf("--port=%d", port), fmt.Sprintf("--httpsport=%d", httpsport), addTLS, diff --git a/cmd/ponzu/options.go b/cmd/ponzu/options.go index 6173368..9023f84 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -303,7 +303,10 @@ func buildPonzuServer(args []string) error { // execute go build -o ponzu-cms cmd/ponzu/*.go buildOptions := []string{"build", "-o", buildOutputName()} - cmdBuildFiles := []string{"main.go", "options.go", "generate.go", "usage.go"} + cmdBuildFiles := []string{ + "main.go", "options.go", "generate.go", + "usage.go", "paths.go", + } var cmdBuildFilePaths []string for _, file := range cmdBuildFiles { p := filepath.Join(pwd, "cmd", "ponzu", file) diff --git a/cmd/ponzu/paths.go b/cmd/ponzu/paths.go index 0ab2b06..73d8d73 100644 --- a/cmd/ponzu/paths.go +++ b/cmd/ponzu/paths.go @@ -2,11 +2,23 @@ package main import "runtime" -// buildOutputName returns the correct ponzu-server file name +// buildOutputName returns the correct ponzu-server file name // based on the host Operating System func buildOutputName() string { if runtime.GOOS == "windows" { return "ponzu-server.exe" } + return "ponzu-server" } + +// buildOutputPath returns the correct path to the ponzu-server binary +// built, based on the host Operating System. This is necessary so that +// the UNIX-y systems know to look in the current directory, and not the $PATH +func buildOutputPath() string { + if runtime.GOOS == "windows" { + return "" + } + + return "." +} |