mirror of
https://github.com/Jguer/yay
synced 2024-10-31 04:12:51 +00:00
Hide pacman output when setting install reason
Stderr is shown if Pacman returns non 0.
This commit is contained in:
parent
0b6e4e0872
commit
111a7f73dc
2 changed files with 37 additions and 4 deletions
33
cmd.go
33
cmd.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
@ -692,6 +693,38 @@ func passToPacman(args *arguments) error {
|
|||
return err
|
||||
}
|
||||
|
||||
//passToPacman but return the output instead of showing the user
|
||||
func passToPacmanCapture(args *arguments) (string, string, error) {
|
||||
var outbuf, errbuf bytes.Buffer
|
||||
var cmd *exec.Cmd
|
||||
argArr := make([]string, 0)
|
||||
|
||||
if args.needRoot() {
|
||||
argArr = append(argArr, "sudo")
|
||||
}
|
||||
|
||||
argArr = append(argArr, config.PacmanBin)
|
||||
argArr = append(argArr, cmdArgs.formatGlobals()...)
|
||||
argArr = append(argArr, args.formatArgs()...)
|
||||
if config.NoConfirm {
|
||||
argArr = append(argArr, "--noconfirm")
|
||||
}
|
||||
|
||||
argArr = append(argArr, "--")
|
||||
|
||||
argArr = append(argArr, args.formatTargets()...)
|
||||
|
||||
cmd = exec.Command(argArr[0], argArr[1:]...)
|
||||
cmd.Stdout = &outbuf
|
||||
cmd.Stderr = &errbuf
|
||||
|
||||
err := cmd.Run()
|
||||
stdout := outbuf.String()
|
||||
stderr := errbuf.String()
|
||||
|
||||
return stdout, stderr, err
|
||||
}
|
||||
|
||||
// passToMakepkg outsources execution to makepkg binary without modifications.
|
||||
func passToMakepkg(dir string, args ...string) (err error) {
|
||||
|
||||
|
|
|
@ -137,9 +137,9 @@ func install(parser *arguments) error {
|
|||
}
|
||||
|
||||
if len(depArguments.targets) > 0 {
|
||||
err = passToPacman(depArguments)
|
||||
_, stderr, err := passToPacmanCapture(depArguments)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%s%s", stderr, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -495,9 +495,9 @@ func buildInstallPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gopkg.PKGBUILD,
|
|||
|
||||
updateVSCdb(bases[pkg.PackageBase], srcinfo)
|
||||
if len(depArguments.targets) > 0 {
|
||||
err = passToPacman(depArguments)
|
||||
_, stderr, err := passToPacmanCapture(depArguments)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("%s%s", stderr, err)
|
||||
}
|
||||
}
|
||||
config.NoConfirm = oldConfirm
|
||||
|
|
Loading…
Reference in a new issue