1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-03-17 20:47:50 +02:00

refactor: set default value of bindir in defaults pipe

Rather than using a conditional to check if `bindir` has been set,
use the defaults pipe to set it to `/usr/local/bin` if it has not
been set in the config file.
This commit is contained in:
Joseph Wright 2017-11-08 09:40:59 -05:00 committed by Carlos Alexandro Becker
parent 5193680e76
commit d9f13a3b12
2 changed files with 8 additions and 6 deletions

View File

@ -75,6 +75,7 @@ func (Pipe) Run(ctx *context.Context) error { // nolint: gocyclo
err := setArchiveDefaults(ctx) err := setArchiveDefaults(ctx)
setDockerDefaults(ctx) setDockerDefaults(ctx)
setFpmDefaults(ctx)
log.WithField("config", ctx.Config).Debug("defaults set") log.WithField("config", ctx.Config).Debug("defaults set")
return err return err
} }
@ -181,3 +182,9 @@ func setArchiveDefaults(ctx *context.Context) error {
} }
return nil return nil
} }
func setFpmDefaults(ctx *context.Context) {
if ctx.Config.FPM.Bindir == "" {
ctx.Config.FPM.Bindir = "/usr/local/bin"
}
}

View File

@ -75,11 +75,6 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
log.WithField("file", file).WithField("workdir", dir).Info("creating fpm archive") log.WithField("file", file).WithField("workdir", dir).Info("creating fpm archive")
var options = basicOptions(ctx, dir, format, arch, file) var options = basicOptions(ctx, dir, format, arch, file)
bindir := "/usr/local/bin"
if ctx.Config.FPM.Bindir != "" {
bindir = ctx.Config.FPM.Bindir
}
for _, binary := range binaries { for _, binary := range binaries {
// This basically tells fpm to put the binary in the bindir, e.g. /usr/local/bin // This basically tells fpm to put the binary in the bindir, e.g. /usr/local/bin
// binary=/usr/local/bin/binary // binary=/usr/local/bin/binary
@ -89,7 +84,7 @@ func create(ctx *context.Context, format, folder, arch string, binaries []contex
options = append(options, fmt.Sprintf( options = append(options, fmt.Sprintf(
"%s=%s", "%s=%s",
binary.Path, binary.Path,
filepath.Join(bindir, binary.Name), filepath.Join(ctx.Config.FPM.Bindir, binary.Name),
)) ))
} }