Skip to content

Commit

Permalink
Allow specifying where stdout should get written (#526)
Browse files Browse the repository at this point in the history
This can be useful when invoking bazelisk programatically.
  • Loading branch information
illicitonion authored Apr 18, 2024
1 parent 24935f4 commit 24651ab
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,12 @@ func RunBazeliskWithArgsFunc(argsFunc ArgsFunc, repos *Repositories) (int, error
// RunBazeliskWithArgsFuncAndConfig runs the main Bazelisk logic for the given ArgsFunc and Bazel
// repositories and config.
func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, config config.Config) (int, error) {
return RunBazeliskWithArgsFuncAndConfigAndOut(argsFunc, repos, config, nil)
}

// RunBazeliskWithArgsFuncAndConfigAndOut runs the main Bazelisk logic for the given ArgsFunc and Bazel
// repositories and config, writing its stdout to the passed writer.
func RunBazeliskWithArgsFuncAndConfigAndOut(argsFunc ArgsFunc, repos *Repositories, config config.Config, out io.Writer) (int, error) {
httputil.UserAgent = getUserAgent(config)

bazeliskHome := config.Get("BAZELISK_HOME")
Expand Down Expand Up @@ -198,7 +204,7 @@ func RunBazeliskWithArgsFuncAndConfig(argsFunc ArgsFunc, repos *Repositories, co
}
}

exitCode, err := runBazel(bazelPath, args, nil, config)
exitCode, err := runBazel(bazelPath, args, out, config)
if err != nil {
return -1, fmt.Errorf("could not run Bazel: %v", err)
}
Expand Down

0 comments on commit 24651ab

Please sign in to comment.