1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-24 04:16:27 +02:00

using cmd.CombinedOutput()

This commit is contained in:
Carlos Alexandro Becker 2017-01-30 08:17:15 -02:00
parent 4ca2bb2101
commit 1c2221b2c5
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 4 additions and 12 deletions

View File

@ -1,7 +1,6 @@
package build
import (
"bytes"
"errors"
"log"
"os"
@ -67,11 +66,8 @@ func run(goos, goarch string, command []string) error {
cmd := exec.Command(command[0], command[1:]...)
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, "GOOS="+goos, "GOARCH="+goarch)
var stdout bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stdout
if err := cmd.Run(); err != nil {
return errors.New(stdout.String())
if out, err := cmd.CombinedOutput(); err != nil {
return errors.New(string(out))
}
return nil
}

View File

@ -1,7 +1,6 @@
package fpm
import (
"bytes"
"errors"
"log"
"os/exec"
@ -82,11 +81,8 @@ func create(ctx *context.Context, format, archive, arch string) error {
options = append(options, name+"="+filepath.Join("/usr/local/bin", name))
cmd := exec.Command("fpm", options...)
var stdout bytes.Buffer
cmd.Stdout = &stdout
cmd.Stderr = &stdout
if err := cmd.Run(); err != nil {
return errors.New(stdout.String())
if out, err := cmd.CombinedOutput(); err != nil {
return errors.New(string(out))
}
return nil
}