Convert bat to powershell: diffing

This commit is contained in:
Dan Hawkins 2021-07-01 08:37:51 +01:00
commit 4339d74109

View file

@ -33,20 +33,17 @@ def comparefiles(importedjsonfile, currentjsonfile) {
# jq -S sorts json output
jq -S . "${importedjsonfile}" > temp1.txt
if (\$lastexitcode -ge 1) { exit 1 }
jq -S . "${importedjsonfile}" > temp2.txt
jq -S . "${currentjsonfile}" > temp2.txt
if (\$lastexitcode -ge 1) { exit 1 }
# echo Diffing sorted json files
\$str1 = Get-Content "temp1.txt"
\$str2 = Get-Content "temp2.txt"
if (\$str1 -ne \$str2) {
Write-Host "Difference between JSON files: "
Compare-Object \$str1 \$str2
exit 1
}
diff.exe -c .\temp1.txt .\temp2.txt
\$lec = \$lastexitcode
Remove-Item temp1.txt
Remove-Item temp2.txt
if (\$lec -ge 1) { exit 1 }
"""
}
}