json-diff icon indicating copy to clipboard operation
json-diff copied to clipboard

outputNewOnly = true loose colours and previous value

Open smartkrio opened this issue 2 years ago • 0 comments

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] 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.

smartkrio avatar Mar 17 '23 05:03 smartkrio