Skip to content

Commit e31b5d5

Browse files
committed
fix: use -l and -w at the same time
1 parent 4dd9d70 commit e31b5d5

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

main.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ func (r *Runner) handleOutput(
279279
info fs.FileInfo,
280280
rp *reporter,
281281
) error {
282-
switch {
283-
case r.dryRun:
282+
if r.dryRun {
284283
pretty, err := diff.Pretty(filename, src, res)
285284
if err != nil {
286285
return err
@@ -291,15 +290,21 @@ func (r *Runner) handleOutput(
291290
}
292291

293292
return nil
293+
}
294+
295+
if !r.listFiles && !r.writeOutput {
296+
_, _ = rp.Write(res)
294297

295-
case r.listFiles:
298+
return nil
299+
}
300+
301+
if r.listFiles {
296302
if !bytes.Equal(src, res) {
297303
_, _ = fmt.Fprintln(rp, filename)
298304
}
305+
}
299306

300-
return nil
301-
302-
case r.writeOutput:
307+
if r.writeOutput {
303308
if filename == "" {
304309
return errors.New("no path to write out to")
305310
}
@@ -317,13 +322,10 @@ func (r *Runner) handleOutput(
317322
return err
318323
}
319324

320-
return nil
321-
322-
default:
323-
_, _ = rp.Write(res)
324-
325325
return nil
326326
}
327+
328+
return nil
327329
}
328330

329331
func deref[T any](v *T) T { //nolint:ireturn

0 commit comments

Comments
 (0)