Fix runDev when running on windows (#33)

Extract default output file to a function and reuse it in both runBuild and runDev
This commit is contained in:
Jayson Reis 2020-08-26 20:36:51 +02:00 committed by GitHub
parent 53742c9c2d
commit 13c49c3566
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -99,11 +99,7 @@ func runBuild(ctx context.Context, args []string) error {
// ensure an output file is always specified
if output == "" {
if runtime.GOOS == "windows" {
output = "caddy.exe"
} else {
output = "caddy"
}
output = getCaddyOutputFile()
}
// perform the build
@ -141,8 +137,15 @@ func runBuild(ctx context.Context, args []string) error {
return nil
}
func getCaddyOutputFile() string {
if runtime.GOOS == "windows" {
return "caddy.exe"
}
return "caddy"
}
func runDev(ctx context.Context, args []string) error {
const binOutput = "./caddy"
binOutput := getCaddyOutputFile()
// get current/main module name
cmd := exec.Command("go", "list", "-m")