Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builder: make Stderr configurable #1656

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions pkg/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ type ParseParams struct {
Experiments *experiments.Set
WorkingDir string
ParseTests bool

// Optional writer to redirect stderr to.
Stderr option.Option[io.Writer]
}

type ParseResult struct {
Expand Down
8 changes: 7 additions & 1 deletion v2/tsbuilder/tsbuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,13 @@ func (i *BuilderImpl) Parse(ctx context.Context, p builder.ParseParams) (*builde
if err != nil {
return nil, fmt.Errorf("unable to get stdin: %s", err)
}
cmd.Stderr = os.Stderr

if stderr, ok := p.Stderr.Get(); ok {
cmd.Stderr = stderr
} else {
cmd.Stderr = os.Stderr
}

if err := cmd.Start(); err != nil {
return nil, fmt.Errorf("unable to start builder: %s", err)
}
Expand Down
Loading