Skip to content

Commit be79b9f

Browse files
slim mageutil
1 parent 0f1ff63 commit be79b9f

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

go.mod

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
module github.com/livekit/mageutil
22

3-
go 1.18
3+
go 1.23.0
44

5-
require golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7
5+
toolchain go1.24.5
6+
7+
require (
8+
github.com/livekit/protocol v1.42.2
9+
golang.org/x/sync v0.16.0
10+
)

go.sum

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1-
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7 h1:ZrnxWX62AgTKOSagEqxvb3ffipvEDX2pl7E1TdqLqIc=
2-
golang.org/x/sync v0.0.0-20220923202941-7f9b1623fab7/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1+
github.com/livekit/protocol v1.42.2 h1:LWzwdIpf/6uNXul5onuMwscbP5BRZwZNI3JHZG0arkw=
2+
github.com/livekit/protocol v1.42.2/go.mod h1:vhMS30QoEyH2p34vi6X1eWkC4EMV72ZGZwQb74ajY7A=
3+
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
4+
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=

slim/slim.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package slim
2+
3+
import (
4+
"context"
5+
"os"
6+
"os/exec"
7+
"strings"
8+
9+
"github.com/livekit/protocol/utils/must"
10+
)
11+
12+
// Each arg is an independent bash script, potentially multi-line.
13+
func Bashes(scripts ...string) {
14+
for _, script := range scripts {
15+
must.Do(bashSingleContextError(context.Background(), script))
16+
}
17+
}
18+
19+
// Each arg is a line of a single bash script.
20+
func Bash(lines ...string) {
21+
Bash(strings.Join(lines, "\n"))
22+
}
23+
24+
func bashSingleContextError(ctx context.Context, script string) error {
25+
cmd := exec.CommandContext(ctx, "/usr/bin/env", "bash", "-c", script)
26+
cmd.Stdin = nil
27+
cmd.Stdout = os.Stdout
28+
cmd.Stderr = os.Stderr
29+
return cmd.Run()
30+
}

0 commit comments

Comments
 (0)