fix(installer): replace orphaned neofetch with fastfetch, surface stderr on Run failure
- neofetch was removed from Arch's official repos; fastfetch is the maintained replacement. - ExecRunner.Run previously discarded stderr, so any 'sudo pacman' failure surfaced only as 'exit status 1'. Now the returned error includes the captured stderr (matching what Output already did).
This commit is contained in:
@@ -13,7 +13,7 @@ packages:
|
|||||||
- zip
|
- zip
|
||||||
- tree
|
- tree
|
||||||
- htop
|
- htop
|
||||||
- neofetch
|
- fastfetch
|
||||||
- ripgrep
|
- ripgrep
|
||||||
- fd
|
- fd
|
||||||
- bat
|
- bat
|
||||||
|
|||||||
@@ -14,9 +14,17 @@ type ExecRunner struct{}
|
|||||||
|
|
||||||
func (ExecRunner) Run(ctx context.Context, name string, args ...string) error {
|
func (ExecRunner) Run(ctx context.Context, name string, args ...string) error {
|
||||||
cmd := exec.CommandContext(ctx, name, args...)
|
cmd := exec.CommandContext(ctx, name, args...)
|
||||||
|
var stderr bytes.Buffer
|
||||||
cmd.Stdout = nil
|
cmd.Stdout = nil
|
||||||
cmd.Stderr = nil
|
cmd.Stderr = &stderr
|
||||||
return cmd.Run()
|
if err := cmd.Run(); err != nil {
|
||||||
|
msg := strings.TrimSpace(stderr.String())
|
||||||
|
if msg == "" {
|
||||||
|
return fmt.Errorf("%s %s: %w", name, strings.Join(args, " "), err)
|
||||||
|
}
|
||||||
|
return fmt.Errorf("%s %s: %w: %s", name, strings.Join(args, " "), err, msg)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ExecRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error) {
|
func (ExecRunner) Output(ctx context.Context, name string, args ...string) ([]byte, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user