Skip to content

Commit

Permalink
fix conflict while running multiple 'protogen' or 'build' commands on…
Browse files Browse the repository at this point in the history
… at the same time
  • Loading branch information
sduchesneau committed Dec 6, 2024
1 parent 1dda42d commit f6ecbc0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cmd/substreams/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,5 +397,9 @@ func runCommandInDir(ctx context.Context, dir string, cmdArgs []string) error {
return fmt.Errorf("error running `%s`: %w", strings.Join(cmdArgs, " "), err)
}

if cmd.ProcessState.ExitCode() != 0 {
return fmt.Errorf("command %q failed with exit code %d", strings.Join(cmdArgs, " "), cmd.ProcessState.ExitCode())
}

return nil
}
9 changes: 8 additions & 1 deletion codegen/proto_generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,14 @@ func NewProtoGenerator(outputPath string, excludedPaths []string, generateMod bo
}

func (g *ProtoGenerator) GenerateProto(pkg *pbsubstreams.Package) error {
spkgTemporaryFilePath := filepath.Join(os.TempDir(), pkg.PackageMeta[0].Name+".tmp.spkg")

tmpDir, err := os.MkdirTemp("", "substreams_protogen")
if err != nil {
return err
}
defer os.RemoveAll(tmpDir)

spkgTemporaryFilePath := filepath.Join(tmpDir, pkg.PackageMeta[0].Name+".tmp.spkg")
cnt, err := proto.Marshal(pkg)
if err != nil {
return fmt.Errorf("marshalling package: %w", err)
Expand Down

0 comments on commit f6ecbc0

Please sign in to comment.