Skip to content

Commit

Permalink
Merge pull request #76 from foomo/ownbrew-errors
Browse files Browse the repository at this point in the history
refactor: ownnbrew error handling
  • Loading branch information
franklinkim authored Jul 30, 2024
2 parents b8492b1 + c275e6e commit 723e618
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions integration/ownbrew/ownbrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ func (o *Ownbrew) Install(ctx context.Context) error {
if install {
if pkg.Tap == "" {
if err := o.installLocal(ctx, pkg); err != nil {
return errors.Wrapf(err, "failed to install local tap: %s", pkg.String())
return errors.Wrap(err, "failed to install local tap")
}
} else {
if err := o.installRemote(ctx, pkg); err != nil {
return errors.Wrapf(err, "failed to install remote tap: %s", pkg.String())
return errors.Wrap(err, "failed to install remote tap")
}
}
} else {
Expand Down Expand Up @@ -236,7 +236,7 @@ func (o *Ownbrew) cellarFilename(name, version string) (string, error) {
func (o *Ownbrew) installLocal(ctx context.Context, pkg Package) error {
filename := filepath.Join(o.tapDir, pkg.Name+".sh")
o.l.Info("installing local:", pkg.String())
o.l.Debug("filename:", filename)
o.l.Info("filename:", filename)

if exists, err := o.localTapExists(filename); err != nil {
return err
Expand Down Expand Up @@ -265,10 +265,9 @@ func (o *Ownbrew) installLocal(ctx context.Context, pkg Package) error {
"TEMP_DIR="+o.tempDir,
)
cmd.Args = append(cmd.Args, pkg.Args...)

o.l.Debug("running:", cmd.String())
if err := cmd.Run(); err != nil {
return errors.Wrapf(err, "failed to install: %s", pkg.String())
if out, err := cmd.CombinedOutput(); err != nil {
return errors.Wrap(err, string(out))
}

return nil
Expand Down Expand Up @@ -324,9 +323,6 @@ func (o *Ownbrew) installRemote(ctx context.Context, pkg Package) error {
cmd.Args = append(cmd.Args, pkg.Args...)
cmd.Stdin = bytes.NewReader(script)
cmd.Stdout = os.Stdout
if err != nil {
return err
}
if o.l.IsLevel(log.LevelDebug) {
cmd.Stderr = os.Stderr
}
Expand Down

0 comments on commit 723e618

Please sign in to comment.