Skip to content

Commit e794909

Browse files
committed
feat: support reading from config.Targets in builds create
1 parent a9be02d commit e794909

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

pkg/cmd/build.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,20 @@ var buildsCompare = cli.Command{
448448
func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
449449
targetPaths := parseTargetPaths()
450450

451+
// Check workspace config for targets
452+
var config WorkspaceConfig
453+
hasWorkspaceTargets := false
454+
found, err := config.Find()
455+
if err == nil && found && config.Targets != nil && len(config.Targets) > 0 {
456+
hasWorkspaceTargets = true
457+
// Merge workspace target paths with command line target paths
458+
for targetName, targetConfig := range config.Targets {
459+
if _, exists := targetPaths[targetName]; !exists && targetConfig.OutputPath != "" {
460+
targetPaths[targetName] = targetConfig.OutputPath
461+
}
462+
}
463+
}
464+
451465
cc, err := getAPICommandContextWithWorkspaceDefaults(cmd)
452466
if err != nil {
453467
return err
@@ -473,7 +487,10 @@ func handleBuildsCreate(ctx context.Context, cmd *cli.Command) error {
473487
return err
474488
}
475489

476-
if cmd.Bool("pull") {
490+
// Pull if explicitly set via --pull flag, or if workspace has configured targets and --pull wasn't explicitly set to false
491+
shouldPull := cmd.Bool("pull") || (hasWorkspaceTargets && !cmd.IsSet("pull"))
492+
493+
if shouldPull {
477494
pullGroup := Info("Downloading build outputs...")
478495
if err := pullBuildOutputs(context.TODO(), cc.client, *res, targetPaths, &pullGroup); err != nil {
479496
pullGroup.Error("Failed to download outputs: %v", err)

0 commit comments

Comments
 (0)