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:
parent
5193680e76
commit
d9f13a3b12
@ -75,6 +75,7 @@ func (Pipe) Run(ctx *context.Context) error { // nolint: gocyclo
|
||||
|
||||
err := setArchiveDefaults(ctx)
|
||||
setDockerDefaults(ctx)
|
||||
setFpmDefaults(ctx)
|
||||
log.WithField("config", ctx.Config).Debug("defaults set")
|
||||
return err
|
||||
}
|
||||
@ -181,3 +182,9 @@ func setArchiveDefaults(ctx *context.Context) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func setFpmDefaults(ctx *context.Context) {
|
||||
if ctx.Config.FPM.Bindir == "" {
|
||||
ctx.Config.FPM.Bindir = "/usr/local/bin"
|
||||
}
|
||||
}
|
||||
|
@ -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")
|
||||
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 {
|
||||
// This basically tells fpm to put the binary in the bindir, e.g. /usr/local/bin
|
||||
// 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(
|
||||
"%s=%s",
|
||||
binary.Path,
|
||||
filepath.Join(bindir, binary.Name),
|
||||
filepath.Join(ctx.Config.FPM.Bindir, binary.Name),
|
||||
))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user