Skip to content

Commit

Permalink
Fix panic writing dependency packages
Browse files Browse the repository at this point in the history
Fix panic in the case where one of the dependencies of the commands has
a build error. In that case, WritePkg p.GoFiles[0] access will fail.

Signed-off-by: Chris Koch <chrisko@google.com>
  • Loading branch information
hugelgupf committed Jul 26, 2023
1 parent 37655b6 commit 491e5be
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/pkg/bb/bbinternal/bb.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,15 @@ func (p *Package) rewriteFile(f *ast.File) bool {

// WritePkg writes p's files into destDir.
func WritePkg(p *packages.Package, destDir string) error {
// TODO(hugelgupf):
// - join errors
// - seems a bit late to check for these errors, but works for now --
// should check when these packages are queried? first used?
// - test
if len(p.Errors) > 0 {
return p.Errors[0]
}

if err := os.MkdirAll(destDir, 0755); err != nil {
return err
}
Expand Down

0 comments on commit 491e5be

Please sign in to comment.