1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00
This commit is contained in:
Carlos Alexandro Becker 2017-05-11 10:47:03 -03:00
parent a6822c53ab
commit 44d9ddd104
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
2 changed files with 5 additions and 5 deletions

View File

@ -57,7 +57,7 @@ func runHook(env []string, hook string) error {
}
log.Println("Running hook", hook)
cmd := strings.Fields(hook)
return run(env, runtimeTarget, cmd)
return run(runtimeTarget, cmd, env)
}
func build(ctx *context.Context, name string, target buildTarget) error {
@ -76,10 +76,10 @@ func build(ctx *context.Context, name string, target buildTarget) error {
return err
}
cmd = append(cmd, "-ldflags="+flags, "-o", output, ctx.Config.Build.Main)
return run(ctx.Config.Build.Env, target, cmd)
return run(target, cmd, ctx.Config.Build.Env)
}
func run(env []string, target buildTarget, command []string) error {
func run(target buildTarget, command, env []string) error {
cmd := exec.Command(command[0], command[1:]...)
cmd.Env = append(cmd.Env, os.Environ()...)
cmd.Env = append(cmd.Env, env...)

View File

@ -19,11 +19,11 @@ func TestPipeDescription(t *testing.T) {
}
func TestRun(t *testing.T) {
assert.NoError(t, run(emptyEnv, runtimeTarget, []string{"go", "list", "./..."}))
assert.NoError(t, run(runtimeTarget, []string{"go", "list", "./..."}, emptyEnv))
}
func TestRunInvalidCommand(t *testing.T) {
assert.Error(t, run(emptyEnv, runtimeTarget, []string{"gggggo", "nope"}))
assert.Error(t, run(runtimeTarget, []string{"gggggo", "nope"}, emptyEnv))
}
func TestBuild(t *testing.T) {