1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-08 03:31:59 +02:00

style: renamed template pkg to filenametemplate

This commit is contained in:
Carlos Alexandro Becker 2017-12-29 11:27:15 -02:00
parent 8a37a654b1
commit 876e5fbe38
No known key found for this signature in database
GPG Key ID: E61E2F7DC14AB940
5 changed files with 17 additions and 17 deletions

View File

@ -1,10 +1,10 @@
// Package template contains the code used to template names of goreleaser's
// packages and archives.
package template
// Package filenametemplate contains the code used to template names of
// goreleaser's packages and archives.
package filenametemplate
import (
"bytes"
gotemplate "text/template"
"text/template"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
@ -39,7 +39,7 @@ func NewFields(ctx *context.Context, a artifact.Artifact, replacements map[strin
// Apply applies the given fields to the given template and returns the
// evaluation and any error that might occur.
func Apply(tmpl string, fields Fields) (string, error) {
t, err := gotemplate.New(tmpl).Parse(tmpl)
t, err := template.New(tmpl).Parse(tmpl)
if err != nil {
return "", err
}

View File

@ -1,4 +1,4 @@
package template
package filenametemplate
import (
"testing"

View File

@ -16,7 +16,7 @@ import (
"github.com/goreleaser/archive"
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/template"
"github.com/goreleaser/goreleaser/internal/filenametemplate"
)
const (
@ -77,9 +77,9 @@ func (Pipe) Run(ctx *context.Context) error {
func create(ctx *context.Context, artifacts []artifact.Artifact) error {
var format = packageFormat(ctx, artifacts[0].Goos)
folder, err := template.Apply(
folder, err := filenametemplate.Apply(
ctx.Config.Archive.NameTemplate,
template.NewFields(ctx, artifacts[0], ctx.Config.Archive.Replacements),
filenametemplate.NewFields(ctx, artifacts[0], ctx.Config.Archive.Replacements),
)
if err != nil {
return err
@ -122,8 +122,8 @@ func create(ctx *context.Context, artifacts []artifact.Artifact) error {
func skip(ctx *context.Context, artifacts []artifact.Artifact) error {
for _, a := range artifacts {
log.WithField("binary", a.Name).Info("skip archiving")
var fields = template.NewFields(ctx, a, ctx.Config.Archive.Replacements)
name, err := template.Apply(ctx.Config.Archive.NameTemplate, fields)
var fields = filenametemplate.NewFields(ctx, a, ctx.Config.Archive.Replacements)
name, err := filenametemplate.Apply(ctx.Config.Archive.NameTemplate, fields)
if err != nil {
return err
}

View File

@ -15,8 +15,8 @@ import (
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/filenametemplate"
"github.com/goreleaser/goreleaser/internal/linux"
"github.com/goreleaser/goreleaser/internal/template"
"github.com/goreleaser/goreleaser/pipeline"
)
@ -86,9 +86,9 @@ func doRun(ctx *context.Context) error {
}
func create(ctx *context.Context, format, arch string, binaries []artifact.Artifact) error {
name, err := template.Apply(
name, err := filenametemplate.Apply(
ctx.Config.FPM.NameTemplate,
template.NewFields(ctx, binaries[0], ctx.Config.FPM.Replacements),
filenametemplate.NewFields(ctx, binaries[0], ctx.Config.FPM.Replacements),
)
if err != nil {
return err

View File

@ -15,8 +15,8 @@ import (
"github.com/goreleaser/goreleaser/context"
"github.com/goreleaser/goreleaser/internal/artifact"
"github.com/goreleaser/goreleaser/internal/filenametemplate"
"github.com/goreleaser/goreleaser/internal/linux"
"github.com/goreleaser/goreleaser/internal/template"
"github.com/goreleaser/goreleaser/pipeline"
)
@ -100,9 +100,9 @@ func (Pipe) Run(ctx *context.Context) error {
func create(ctx *context.Context, arch string, binaries []artifact.Artifact) error {
var log = log.WithField("arch", arch)
folder, err := template.Apply(
folder, err := filenametemplate.Apply(
ctx.Config.Snapcraft.NameTemplate,
template.NewFields(ctx, binaries[0], ctx.Config.Snapcraft.Replacements),
filenametemplate.NewFields(ctx, binaries[0], ctx.Config.Snapcraft.Replacements),
)
if err != nil {
return err