MCPcopy Index your code
hub / github.com/TheThingsNetwork/lorawan-stack / execFrom

Function execFrom

tools/mage/dev.go:381–405  ·  view source on GitHub ↗
(
	dir string, env map[string]string, stdout, stderr io.Writer, cmd string, args ...string,
)

Source from the content-addressed store, hash-verified

379}
380
381func execFrom(
382 dir string, env map[string]string, stdout, stderr io.Writer, cmd string, args ...string,
383) error {
384 c := exec.Command(cmd, args...)
385 c.Env = os.Environ()
386 for k, v := range env {
387 c.Env = append(c.Env, k+"="+v)
388 }
389 c.Dir = dir
390 c.Stderr = stderr
391 c.Stdout = stdout
392 c.Stdin = os.Stdin
393 if mg.Verbose() {
394 log.Println("exec:", cmd, strings.Join(args, " "))
395 }
396 err := c.Run()
397 if err == nil {
398 return nil
399 }
400 ran, code := sh.CmdRan(err), sh.ExitStatus(err)
401 if ran {
402 return mg.Fatalf(code, `running "%s %s" failed with exit code %d`, cmd, strings.Join(args, " "), code)
403 }
404 return fmt.Errorf(`failed to run "%s %s: %w"`, cmd, strings.Join(args, " "), err)
405}

Callers 2

StartDevStackMethod · 0.85
execGoFromFunction · 0.85

Calls 4

JoinMethod · 0.65
RunMethod · 0.65
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected