forked from Silverfish/proton-bridge
GODT-2150: fixed initial implementation that filtered --no-window in gui instead of bridge.
This commit is contained in:
@ -77,7 +77,7 @@ func (restarter *Restarter) Restart() {
|
||||
//nolint:gosec
|
||||
cmd := execabs.Command(
|
||||
restarter.exe,
|
||||
xslices.Join(removeFlagWithValue(os.Args[1:], "parent-pid"), restarter.flags)...,
|
||||
xslices.Join(removeFlagWithValue(removeFlag(os.Args[1:], "no-window"), "parent-pid"), restarter.flags)...,
|
||||
)
|
||||
|
||||
l := logrus.WithFields(logrus.Fields{
|
||||
@ -156,3 +156,7 @@ func removeFlagWithValue(argList []string, flag string) []string {
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
func removeFlag(argList []string, flag string) []string {
|
||||
return xslices.Filter(argList, func(arg string) bool { return (arg != "-"+flag) && (arg != "--"+flag) })
|
||||
}
|
||||
|
||||
@ -41,3 +41,20 @@ func TestRemoveFlagWithValue(t *testing.T) {
|
||||
require.Equal(t, removeFlagWithValue(tt.argList, tt.flag), tt.expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestRemoveFlag(t *testing.T) {
|
||||
tests := []struct {
|
||||
argList []string
|
||||
flag string
|
||||
expected []string
|
||||
}{
|
||||
{[]string{}, "b", []string{}},
|
||||
{[]string{"-a", "-b", "-c"}, "b", []string{"-a", "-c"}},
|
||||
{[]string{"-a", "--b", "-b"}, "b", []string{"-a"}},
|
||||
{[]string{"-a", "-c"}, "b", []string{"-a", "-c"}},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
require.Equal(t, removeFlag(tt.argList, tt.flag), tt.expected)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user