Skip to content

Commit

Permalink
Remove compare-strings
Browse files Browse the repository at this point in the history
  • Loading branch information
Rem0o committed Oct 18, 2024
1 parent 2c62895 commit f1462e6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
6 changes: 3 additions & 3 deletions ThemePage/ThemePage.de.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
{
"Input": "Eingabe",
"Previews": "Vorschau",
"Primary": "Primär",
"Primary": "Prim�r",
"SampleText": "Beispieltext",
"Secondary": "Sekundär",
"Secondary": "Sekund�r",
"SyncThemeWindows": "An Windows-Design anpassen",
"Theme": "Design"
}
2 changes: 1 addition & 1 deletion ThemePage/ThemePage.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"Input": "Input",
"Previews": "Previews",
"Primary": "Primary",
Expand Down
15 changes: 6 additions & 9 deletions format-json.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ param (
[switch]$Fix = $false
)

$newline = "`r`n"

function Format-Json {
Param(
[Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true)]
Expand Down Expand Up @@ -50,7 +52,6 @@ function Format-Json {
$line
}

$newline = "`r`n"
$res = ($result -Join $newline)

return $res
Expand Down Expand Up @@ -112,7 +113,7 @@ function ConvertTo-OrderedDictionaryFromArray {

$fullPath = $Path | Resolve-Path
Write-Output "Scanning $fullPath"
Write-Output "${[Environment]::NewLine}"
Write-Output "$newline"

$baseFiles = Get-ChildItem -Path $Path -Filter "*.json" -Recurse | Where-Object { $_.Name -notmatch "\.[a-z]{2}(-[a-z]{2})?\.json$" }

Expand Down Expand Up @@ -156,9 +157,7 @@ foreach ($baseFile in $baseFiles) {
$formattedTranslationJson = ConvertTo-OrderedDictionaryFromArray($translation.GetEnumerator() | Sort-Object -Property Name) | ConvertTo-Json -Depth 100 | Format-Json -Indentation 2
if ($formattedTranslationJson -ne $translationJson) {
$exitCode = -1
$problem = "Formatting for [$translationFile] is wrong"

Compare-Strings -string1 $formattedTranslationJson -string2 $translationJson
$problem += "Formatting for [$translationFile] is wrong" + $newline

if ($Fix) {
Write-Output "Formatting [$translationFile]"
Expand All @@ -171,9 +170,7 @@ foreach ($baseFile in $baseFiles) {
$formattedBaseJson = ConvertTo-OrderedDictionaryFromArray( $baseDictionary.GetEnumerator() | Sort-Object -Property Name) | ConvertTo-Json -Depth 100 | Format-Json -Indentation 2
if ($formattedBaseJson -ne $baseJson) {
$exitCode = -1;
$problem = "Formatting for [$baseFile] is wrong"

Compare-Strings -string1 $formattedBaseJson -string2 $baseJson
$problem += "Formatting for [$baseFile] is wrong" + $newline

if ($Fix) {
Write-Output "Formatting [$baseFile]"
Expand All @@ -182,7 +179,7 @@ foreach ($baseFile in $baseFiles) {
}
}

Write-Output "${[Environment]::NewLine}"
Write-Output "$newline"
if ($Fix -and ($exitCode -eq -1)) {
$exitCode = 0
}
Expand Down

0 comments on commit f1462e6

Please sign in to comment.