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

homebrew: fix indent on template and remove install commands logic from it

This commit is contained in:
Paulo Sousa 2017-03-09 15:33:45 -03:00
parent 938b50c399
commit a5104aca17
2 changed files with 9 additions and 13 deletions

View File

@ -37,22 +37,12 @@ const formula = `class {{ .Name }} < Formula
{{- end }}
{{- end }}
{{- if .Install }}
def install
{{- range $index, $element := .Install }}
{{ . -}}
{{- end }}
{{- end }}
end
{{- else }}
def install
bin.install "{{ .BinaryName }}"
end
{{- end }}
{{- if .Caveats }}
def caveats
@ -162,6 +152,7 @@ func dataFor(
) (result templateData, err error) {
var homepage string
var description string
var installCmds string
rep, _, err := client.Repositories.Get(
ctx, ctx.ReleaseRepo.Owner, ctx.ReleaseRepo.Name,
)
@ -186,6 +177,12 @@ func dataFor(
} else {
description = *rep.Description
}
if ctx.Config.Brew.Install != "" {
installCmds = ctx.Config.Brew.Install
} else {
installCmds = "bin.install \"" + ctx.Config.Build.BinaryName + "\""
}
return templateData{
Name: formulaNameFor(ctx.Config.Build.BinaryName),
Desc: description,
@ -201,7 +198,7 @@ func dataFor(
Dependencies: ctx.Config.Brew.Dependencies,
Conflicts: ctx.Config.Brew.Conflicts,
Plist: ctx.Config.Brew.Plist,
Install: strings.Split(ctx.Config.Brew.Install, "\n"),
Install: strings.Split(installCmds, "\n"),
}, err
}

View File

@ -68,7 +68,6 @@ func TestFormulaeSimple(t *testing.T) {
assert.NoError(err)
formulae := out.String()
assertDefaultTemplateData(t, formulae)
assert.Contains(formulae, "bin.install \"test\"")
assert.NotContains(formulae, "def caveats")
assert.NotContains(formulae, "depends_on")
assert.NotContains(formulae, "def plist;")