Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
module github.com/livekit/mageutil

go 1.18
go 1.23.0

require golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7
toolchain go1.24.5

require (
github.com/livekit/protocol v1.42.2
golang.org/x/sync v0.16.0
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 h1:ZrnxWX62AgTKOSagEqxvb3ffipvEDX2pl7E1TdqLqIc=
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
github.com/livekit/protocol v1.42.2 h1:LWzwdIpf/6uNXul5onuMwscbP5BRZwZNI3JHZG0arkw=
github.com/livekit/protocol v1.42.2/go.mod h1:vhMS30QoEyH2p34vi6X1eWkC4EMV72ZGZwQb74ajY7A=
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
30 changes: 30 additions & 0 deletions slim/slim.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package slim

import (
"context"
"os"
"os/exec"
"strings"

"github.com/livekit/protocol/utils/must"
)

// Each arg is an independent bash script, potentially multi-line.
func Bashes(scripts ...string) {
for _, script := range scripts {
must.Do(bashSingleContextError(context.Background(), script))
}
}

// Each arg is a line of a single bash script.
func Bash(lines ...string) {
Bashes(strings.Join(lines, "\n"))
}

func bashSingleContextError(ctx context.Context, script string) error {
cmd := exec.CommandContext(ctx, "/usr/bin/env", "bash", "-c", script)
cmd.Stdin = nil
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Run()
}