mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-03-17 20:47:50 +02:00
feat: add args to snapcraft commands
This commit is contained in:
parent
d41703227c
commit
0c67099381
@ -206,6 +206,7 @@ type Sign struct {
|
||||
type SnapcraftAppMetadata struct {
|
||||
Plugs []string
|
||||
Daemon string
|
||||
Args string
|
||||
}
|
||||
|
||||
// Snapcraft config
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/apex/log"
|
||||
"golang.org/x/sync/errgroup"
|
||||
@ -153,6 +154,10 @@ func create(ctx *context.Context, arch string, binaries []artifact.Artifact) err
|
||||
if configAppMetadata, ok := ctx.Config.Snapcraft.Apps[binary.Name]; ok {
|
||||
appMetadata.Plugs = configAppMetadata.Plugs
|
||||
appMetadata.Daemon = configAppMetadata.Daemon
|
||||
appMetadata.Command = strings.Join([]string{
|
||||
appMetadata.Command,
|
||||
configAppMetadata.Args,
|
||||
}, " ")
|
||||
}
|
||||
metadata.Apps[binary.Name] = appMetadata
|
||||
|
||||
|
@ -107,7 +107,7 @@ func TestRunPipeWithName(t *testing.T) {
|
||||
assert.Equal(t, metadata.Name, "testsnapname")
|
||||
}
|
||||
|
||||
func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
func TestRunPipeMetadata(t *testing.T) {
|
||||
folder, err := ioutil.TempDir("", "archivetest")
|
||||
assert.NoError(t, err)
|
||||
var dist = filepath.Join(folder, "dist")
|
||||
@ -124,6 +124,7 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
"mybin": {
|
||||
Plugs: []string{"home", "network"},
|
||||
Daemon: "simple",
|
||||
Args: "--foo --bar",
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -138,6 +139,7 @@ func TestRunPipeWithPlugsAndDaemon(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, metadata.Apps["mybin"].Plugs, []string{"home", "network"})
|
||||
assert.Equal(t, metadata.Apps["mybin"].Daemon, "simple")
|
||||
assert.Equal(t, metadata.Apps["mybin"].Command, "mybin --foo --bar")
|
||||
}
|
||||
|
||||
func TestNoSnapcraftInPath(t *testing.T) {
|
||||
|
@ -239,6 +239,10 @@ snapcraft:
|
||||
# If you want your app to be autostarted and to always run in the
|
||||
# background, you can make it a simple daemon.
|
||||
daemon: simple
|
||||
|
||||
# If you any to pass args to your binary, you can add them with the
|
||||
# args option.
|
||||
args: --foo
|
||||
```
|
||||
|
||||
Note that GoReleaser will not install `snapcraft` nor any of its dependencies
|
||||
|
Loading…
x
Reference in New Issue
Block a user