Skip to content

Commit

Permalink
Fix runDev when running on windows (#33)
Browse files Browse the repository at this point in the history
Extract default output file to a function and reuse it in both runBuild and runDev
  • Loading branch information
jaysonsantos authored Aug 26, 2020
1 parent 53742c9 commit 13c49c3
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cmd/xcaddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit 13c49c3

Please sign in to comment.