Comparing version 0.0.5 to 0.0.6
{ | ||
"name": "jscmp", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Compare two JSON/JS files to find the diff between their exported objects", | ||
@@ -5,0 +5,0 @@ "author": "Ayush Gupta <AyushG3112@gmail.com>", |
@@ -17,4 +17,8 @@ class DefaultHandler { | ||
case "missing": | ||
let missingIn = "fileA"; | ||
if (item.typeB === "undefined") { | ||
missingIn = "fileB"; | ||
} | ||
console.log( | ||
`Field: ${item.field} missing.\nType in fileA: ${item.typeA}.\nType in fileB: ${item.typeB}.\n` | ||
`Field: ${item.field} missing in ${missingIn}.` | ||
); | ||
@@ -24,3 +28,3 @@ break; | ||
console.log( | ||
`Field: ${item.field} has different types in both files.\nType in fileA: ${item.typeA}.\nType in fileB: ${item.typeB}.\n` | ||
`\nField: ${item.field} has different types in both files.\nType in fileA: ${item.typeA}.\nType in fileB: ${item.typeB}.\n` | ||
); | ||
@@ -27,0 +31,0 @@ break; |
@@ -11,3 +11,3 @@ import { getArrayDiff, getArrayIntersection, getType } from "../utils"; | ||
const keysB = Object.keys(dataB); | ||
const common = getArrayIntersection(keysA, keysB) | ||
const common = getArrayIntersection(keysA, keysB); | ||
const aDiff = getArrayDiff(keysA, keysB); | ||
@@ -36,6 +36,4 @@ const bDiff = getArrayDiff(keysB, keysA); | ||
for (let key of common) { | ||
if ( | ||
getType(dataA[key]) !== | ||
getType(dataB[key]) | ||
) { | ||
console.log(key); | ||
if (getType(dataA[key]) !== getType(dataB[key])) { | ||
outputArray.push({ | ||
@@ -49,5 +47,3 @@ type: "typeMismatch", | ||
}); | ||
} else if ( | ||
getType(dataA[key]) == "[object Object]" | ||
) { | ||
} else if (getType(dataA[key]) == "object") { | ||
comparer( | ||
@@ -54,0 +50,0 @@ { fileA, dataA: dataA[key] }, |
8123