fix(install): fix missing error display in install

This commit is contained in:
jguer 2021-08-21 16:17:19 +02:00
parent cedbcfbcda
commit b7f9a5e677
No known key found for this signature in database
GPG Key ID: 6D6CC9BEA8556B35
3 changed files with 16 additions and 8 deletions

14
cmd.go
View File

@ -6,6 +6,7 @@ import (
"fmt"
"net/http"
"os"
"strings"
alpm "github.com/Jguer/go-alpm/v2"
"github.com/leonelquinteros/gotext"
@ -222,8 +223,17 @@ func handleQuery(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.E
return printUpdateList(ctx, cmdArgs, dbExecutor, cmdArgs.ExistsDouble("u", "sysupgrade"), filter)
}
return config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm))
if err := config.Runtime.CmdBuilder.Show(config.Runtime.CmdBuilder.BuildPacmanCmd(ctx,
cmdArgs, config.Runtime.Mode, settings.NoConfirm)); err != nil {
if str := err.Error(); strings.Contains(str, "exit status") {
// yay -Qdt should not output anything in case of error
return fmt.Errorf("")
}
return err
}
return nil
}
func handleHelp(ctx context.Context, cmdArgs *parser.Arguments) error {

View File

@ -262,7 +262,7 @@ func install(ctx context.Context, cmdArgs *parser.Arguments, dbExecutor db.Execu
cloned, errA := download.AURPKGBUILDRepos(ctx,
config.Runtime.CmdBuilder, toClone, config.AURURL, config.BuildDir, false)
if errA != nil {
return err
return errA
}
var (

View File

@ -5,7 +5,6 @@ import (
"fmt"
"os"
"os/exec"
"strings"
pacmanconf "github.com/Morganamilo/go-pacmanconf"
"github.com/leonelquinteros/gotext"
@ -161,11 +160,10 @@ func main() {
}
defer dbExecutor.Cleanup()
err = handleCmd(ctx, cmdArgs, db.Executor(dbExecutor))
if err != nil {
if str := err.Error(); str != "" && !strings.Contains(str, "exit status") {
fmt.Fprintln(os.Stderr, str)
if err = handleCmd(ctx, cmdArgs, db.Executor(dbExecutor)); err != nil {
if str := err.Error(); str != "" {
text.Errorln(str)
}
if exitError, ok := err.(*exec.ExitError); ok {