Skip to content

Commit 5ebd352

Browse files
authored
fix: use a clean output directory for each API when generating (#1836)
An alternative would be to clean the output directory after each library is generated, but keeping them all (separately) will make it easier to diagnose problems. Fixes #1774
1 parent 1f288c8 commit 5ebd352

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

internal/librarian/generate.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,15 @@ func (r *generateRunner) generateSingleLibrary(ctx context.Context, libraryID, o
175175
libraryID = configuredLibraryID
176176
}
177177

178-
generatedLibraryID, err := r.runGenerateCommand(ctx, libraryID, outputDir)
178+
// For each library, create a separate output directory. This avoids
179+
// libraries interfering with each other, and makes it easier to see what
180+
// was generated for each library when debugging.
181+
libraryOutputDir := filepath.Join(outputDir, libraryID)
182+
if err := os.Mkdir(libraryOutputDir, 0755); err != nil {
183+
return err
184+
}
185+
186+
generatedLibraryID, err := r.runGenerateCommand(ctx, libraryID, libraryOutputDir)
179187
if err != nil {
180188
return err
181189
}

0 commit comments

Comments
 (0)