Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outputNewOnly = true loose colours and previous value #110

Open
smartkrio opened this issue Mar 17, 2023 · 0 comments
Open

outputNewOnly = true loose colours and previous value #110

smartkrio opened this issue Mar 17, 2023 · 0 comments

Comments

@smartkrio
Copy link

smartkrio commented Mar 17, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant