Skip to content

Commit 79e01a0

Browse files
authored
chore: Revert "chore: Revert "feat: set default output for sources (#1453)"" (#1474)
Reverts #1471
1 parent f8baecf commit 79e01a0

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

internal/run/source.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,11 @@ func getTempApplyPath(path string) string {
275275

276276
// Reformats yaml to json if necessary and writes to the output location
277277
func writeToOutputLocation(ctx context.Context, documentPath string, outputLocation string) error {
278+
// If paths are the same, no need to do anything
279+
if documentPath == outputLocation {
280+
return nil
281+
}
282+
278283
// If we have yaml and need json, convert it
279284
if utils.HasYAMLExt(documentPath) && !utils.HasYAMLExt(outputLocation) {
280285
jsonBytes, err := schemas.Format(ctx, documentPath, false)
@@ -284,8 +289,8 @@ func writeToOutputLocation(ctx context.Context, documentPath string, outputLocat
284289

285290
return os.WriteFile(outputLocation, jsonBytes, 0o644)
286291
} else {
287-
// Otherwise, just rename the file
288-
return os.Rename(documentPath, outputLocation)
292+
// Otherwise, just copy the file over
293+
return utils.CopyFile(documentPath, outputLocation)
289294
}
290295
}
291296

prompts/sources.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ func sourceBaseForm(ctx context.Context, quickstart *Quickstart) (*QuickstartSta
289289
}
290290
source.Inputs = append(source.Inputs, *document)
291291

292+
if authHeader == "" && (source.Output == nil || *source.Output == "") {
293+
// Set default output path for source
294+
defaultOutput := ".speakeasy/out.openapi.yaml"
295+
source.Output = &defaultOutput
296+
}
297+
292298
if registry.IsRegistryEnabled(ctx) && orgSlug != "" && auth.GetWorkspaceSlugFromContext(ctx) != "" {
293299
if err := configureRegistry(source, orgSlug, auth.GetWorkspaceSlugFromContext(ctx), sourceName); err != nil {
294300
return nil, err

0 commit comments

Comments
 (0)