mirror of
https://github.com/goreleaser/nfpm
synced 2024-06-10 02:06:12 +02:00
fix: expand
This commit is contained in:
parent
87985355f6
commit
318650ee5a
|
@ -59,6 +59,7 @@ type Content struct {
|
|||
Type string `yaml:"type,omitempty" json:"type,omitempty" jsonschema:"enum=symlink,enum=ghost,enum=config,enum=config|noreplace,enum=dir,enum=tree,enum=,default="`
|
||||
Packager string `yaml:"packager,omitempty" json:"packager,omitempty"`
|
||||
FileInfo *ContentFileInfo `yaml:"file_info,omitempty" json:"file_info,omitempty"`
|
||||
Expand bool `yaml:"expand,omitempty" json:"expand,omitempty"`
|
||||
}
|
||||
|
||||
type ContentFileInfo struct {
|
||||
|
|
3
nfpm.go
3
nfpm.go
|
@ -174,6 +174,9 @@ func (c *Config) expandEnvVarsStringSlice(items []string) []string {
|
|||
func (c *Config) expandEnvVarsContents(contents files.Contents) files.Contents {
|
||||
for i := range contents {
|
||||
f := contents[i]
|
||||
if !f.Expand {
|
||||
continue
|
||||
}
|
||||
f.Destination = strings.TrimSpace(os.Expand(f.Destination, c.envMappingFunc))
|
||||
f.Source = strings.TrimSpace(os.Expand(f.Source, c.envMappingFunc))
|
||||
}
|
||||
|
|
21
nfpm_test.go
21
nfpm_test.go
|
@ -516,21 +516,28 @@ name: foo
|
|||
contents:
|
||||
- src: '${NAME}_${ARCH}'
|
||||
dst: /usr/bin/${NAME}
|
||||
expand: true
|
||||
- src: '${NAME}'
|
||||
dst: /usr/bin/bar
|
||||
|
||||
overrides:
|
||||
deb:
|
||||
contents:
|
||||
- src: '${NAME}_${ARCH}'
|
||||
dst: /debian/usr/bin/${NAME}
|
||||
expand: true
|
||||
`))
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, info.Contents.Len())
|
||||
contentq := info.Contents[0]
|
||||
require.Equal(t, "/usr/bin/foo", contentq.Destination)
|
||||
require.Equal(t, "foo_amd64", contentq.Source)
|
||||
content2 := info.Overrides["deb"].Contents[0]
|
||||
require.Equal(t, "/debian/usr/bin/foo", content2.Destination)
|
||||
require.Equal(t, "foo_amd64", content2.Source)
|
||||
require.Equal(t, 2, info.Contents.Len())
|
||||
content1 := info.Contents[0]
|
||||
require.Equal(t, "/usr/bin/foo", content1.Destination)
|
||||
require.Equal(t, "foo_amd64", content1.Source)
|
||||
content2 := info.Contents[1]
|
||||
require.Equal(t, "/usr/bin/bar", content2.Destination)
|
||||
require.Equal(t, "${NAME}", content2.Source)
|
||||
content3 := info.Overrides["deb"].Contents[0]
|
||||
require.Equal(t, "/debian/usr/bin/foo", content3.Destination)
|
||||
require.Equal(t, "foo_amd64", content3.Source)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue