diff options
-rw-r--r-- | cmd/ponzu/main.go | 6 | ||||
-rw-r--r-- | cmd/ponzu/options.go | 7 | ||||
-rw-r--r-- | cmd/ponzu/paths.go | 24 |
3 files changed, 34 insertions, 3 deletions
diff --git a/cmd/ponzu/main.go b/cmd/ponzu/main.go index d064569..c324a88 100644 --- a/cmd/ponzu/main.go +++ b/cmd/ponzu/main.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "strings" "github.com/ponzu-cms/ponzu/system/admin" @@ -146,7 +147,10 @@ func main() { services = "admin,api" } - serve := exec.Command("./ponzu-server", + 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 43f6e05..9023f84 100644 --- a/cmd/ponzu/options.go +++ b/cmd/ponzu/options.go @@ -302,8 +302,11 @@ func buildPonzuServer(args []string) error { } // execute go build -o ponzu-cms cmd/ponzu/*.go - buildOptions := []string{"build", "-o", "ponzu-server"} - cmdBuildFiles := []string{"main.go", "options.go", "generate.go", "usage.go"} + buildOptions := []string{"build", "-o", buildOutputName()} + 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 new file mode 100644 index 0000000..73d8d73 --- /dev/null +++ b/cmd/ponzu/paths.go @@ -0,0 +1,24 @@ +package main + +import "runtime" + +// 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 "." +} |