Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit f5fbfe4

Browse files
committed
Print new lock file contents during dry-run
1 parent 2287888 commit f5fbfe4

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

txn_writer.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -358,12 +358,21 @@ func (sw *SafeWriter) PrintPreparedActions() error {
358358
}
359359

360360
if sw.Payload.HasLock() {
361-
fmt.Println("Would have written the following changes to lock.json:")
362-
diff, err := sw.Payload.LockDiff.Format()
363-
if err != nil {
364-
return errors.Wrap(err, "ensure DryRun cannot serialize the lock diff")
361+
if sw.Payload.LockDiff == nil {
362+
fmt.Println("Would have written the following lock.json:")
363+
l, err := sw.Payload.Lock.MarshalJSON()
364+
if err != nil {
365+
return errors.Wrap(err, "ensure DryRun cannot serialize lock")
366+
}
367+
fmt.Println(string(l))
368+
} else {
369+
fmt.Println("Would have written the following changes to lock.json:")
370+
diff, err := sw.Payload.LockDiff.Format()
371+
if err != nil {
372+
return errors.Wrap(err, "ensure DryRun cannot serialize the lock diff")
373+
}
374+
fmt.Println(diff)
365375
}
366-
fmt.Println(diff)
367376
}
368377

369378
if sw.Payload.HasVendor() {

0 commit comments

Comments
 (0)