Skip to content

outputNewOnly = true loose colours and previous value #110

Description

@smartkrio

Hi! 馃憢

Firstly, thanks for your work on this project! 馃檪

Today I used patch-package to patch json-diff@1.0.3 for the project I'm working on.

Hello guys, I've make some changes to keep nice colourful output with previous value if outputNewOnly flag is true.

Here is the diff that solved my problem:

diff --git a/node_modules/json-diff/lib/index.js b/node_modules/json-diff/lib/index.js
index f06a825..19250bd 100644
--- a/node_modules/json-diff/lib/index.js
+++ b/node_modules/json-diff/lib/index.js
@@ -312,12 +312,7 @@ class JsonDiff {
       }
       if (!equal) {
         score = 0
-
-        if (this.options.outputNewOnly) {
-          result = obj2
-        } else {
-          result = { __old: obj1, __new: obj2 }
-        }
+        result = { __old: obj1, __new: obj2 }
       } else if (!this.options.full) {
         result = undefined
       }

The result will be
image

This issue body was partially generated by patch-package.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions