Skip to content

Conversation

@sitaktif
Copy link

This allows library users to control what happens with stderr (e.g. write it to a file or buffer instead of the process' stderr).

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for custom stderr handling in Bazelisk's Go library API, allowing library consumers to redirect stderr output to custom writers instead of always using the process's stderr. This enhancement improves the flexibility of Bazelisk when used as a library.

Changes:

  • Added new public API function RunBazeliskWithArgsFuncAndConfigAndOutAndErr that accepts both stdout and stderr writers
  • Updated internal functions makeBazelCmd and runBazel to accept and handle custom stderr writers
  • Maintained backward compatibility by having existing functions delegate to the new function with nil for stderr

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// RunBazeliskWithArgsFuncAndConfigAndOutAndErr runs the main Bazelisk logic for the given ArgsFunc and Bazel
// repositories and config, writing its stdout and stderr to the passed writer.
func RunBazeliskWithArgsFuncAndConfigAndOutAndErr(argsFunc ArgsFunc, repos *Repositories, config config.Config, stdout, stderr io.Writer) (int, error) {
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new stderr parameter functionality in RunBazeliskWithArgsFuncAndConfigAndOutAndErr lacks test coverage. Consider adding a test that verifies stderr can be redirected to a custom writer, similar to how stdout redirection should work. This would help ensure the feature works as intended and prevents regressions.

Copilot uses AI. Check for mistakes.
}

// RunBazeliskWithArgsFuncAndConfigAndOutAndErr runs the main Bazelisk logic for the given ArgsFunc and Bazel
// repositories and config, writing its stdout and stderr to the passed writer.
Copy link

Copilot AI Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The documentation incorrectly states that both stdout and stderr are written to "the passed writer" (singular), but the function signature shows two separate writers for stdout and stderr respectively. The documentation should clarify that stdout is written to the first writer and stderr is written to the second writer, or say "the passed writers" (plural).

Suggested change
// repositories and config, writing its stdout and stderr to the passed writer.
// repositories and config, writing its stdout to the first passed writer and stderr to the second.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant