Skip to content

Commit a608129

Browse files
committed
better --force errors
1 parent 3b2a2b6 commit a608129

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/app/azldev/cmds/component/render.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,13 @@ func RenderComponents(env *azldev.Env, options *RenderOptions) ([]*RenderResult,
172172
options.Force)
173173

174174
// Clean up stale rendered directories when rendering all components.
175-
// Only runs when --force is set (auto-set for configured dirs).
176-
if options.ComponentFilter.IncludeAllComponents && options.Force {
175+
// Requires --force (auto-set for configured dirs) to prevent accidental deletion.
176+
if options.ComponentFilter.IncludeAllComponents {
177+
if !options.Force {
178+
return nil, errors.New(
179+
"rendering all components (-a) requires --force to enable cleanup of stale output directories")
180+
}
181+
177182
if cleanupErr := cleanupStaleRenders(env.FS(), comps, options.OutputDir); cleanupErr != nil {
178183
return results, fmt.Errorf("cleaning up stale rendered output:\n%w", cleanupErr)
179184
}
@@ -644,7 +649,7 @@ func copyRenderedOutput(env *azldev.Env, tempDir, baseOutputDir, componentName s
644649
if exists {
645650
if !allowOverwrite {
646651
return fmt.Errorf(
647-
"output directory %#q already exists; external output directories are not overwritten",
652+
"output directory %#q already exists; use --force to overwrite",
648653
componentOutputDir)
649654
}
650655

0 commit comments

Comments
 (0)