From 67c272f5c38905d285992ce0d6a1ec20239fd23c Mon Sep 17 00:00:00 2001 From: Dan Hawkins Date: Wed, 7 Apr 2021 13:10:51 +0100 Subject: [PATCH] AHBKM1024A-88 - Compare json files in windows --- differences/json.groovy | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/differences/json.groovy b/differences/json.groovy index 5ac37f2..6417d04 100644 --- a/differences/json.groovy +++ b/differences/json.groovy @@ -8,7 +8,27 @@ def comparefiles(importedjsonfile, currentjsonfile) { """ } else { - error "Windows not currently supporting json file comparison" + // Jq and diffutils can be installed on windows with chocolatey + sh """ + where jq + if errorlevel 1 EXIT /b 1 + where diff + if errorlevel 1 EXIT /b 1 + + # jq -S sorts json output + jq -S . "${importedjsonfile}" > temp1.txt + if errorlevel 1 EXIT /b 1 + jq -S . "${importedjsonfile}" > temp2.txt + if errorlevel 1 EXIT /b 1 + + diff -c temp1.txt temp2.txt + set el=%errorlevel% + + del temp1.txt + del temp2.txt + + if el GEQ 1 EXIT /b 1 + """ } }