5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-19 10:29:29 +08:00

[v2] Fix error messages in dev mode

This commit is contained in:
Lea Anthony 2021-10-07 18:56:53 +11:00
parent 1ae9469e90
commit 6943b657c9

View File

@ -3,7 +3,6 @@ package dev
import ( import (
"context" "context"
"fmt" "fmt"
"github.com/wailsapp/wails/v2/internal/shell"
"io" "io"
"net/http" "net/http"
"os" "os"
@ -108,12 +107,12 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
} }
// Run go mod tidy to ensure we're up to date // Run go mod tidy to ensure we're up to date
err = runCommand(cwd, "go", "mod", "tidy") err = runCommand(cwd, false, "go", "mod", "tidy")
if err != nil { if err != nil {
return err return err
} }
err = runCommand(cwd, "wails", "generate", "module") err = runCommand(cwd, true, "wails", "generate", "module")
if err != nil { if err != nil {
return err return err
} }
@ -195,10 +194,16 @@ func AddSubcommand(app *clir.Cli, w io.Writer) error {
return nil return nil
} }
func runCommand(cwd string, command string, args ...string) error { func runCommand(dir string, exitOnError bool, command string, args ...string) error {
LogGreen("Executing: " + command + " " + strings.Join(args, " ")) LogGreen("Executing: " + command + " " + strings.Join(args, " "))
_, _, err := shell.RunCommand(cwd, command, args...) cmd := exec.Command(command, args...)
cmd.Dir = dir
output, err := cmd.CombinedOutput()
if err != nil { if err != nil {
println(string(output))
if exitOnError {
os.Exit(1)
}
return err return err
} }
return nil return nil