Skip to content

Commit

Permalink
lint(format-json)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash258 committed May 8, 2020
1 parent 86ac243 commit d72ee12
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions bin/formatjson.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Format manifest.
.PARAMETER App
Manifest to format.
Wildcards are supported.
.PARAMETER Dir
Where to search for manifest(s).
.EXAMPLE
Expand Down Expand Up @@ -34,13 +32,13 @@ param(

$Dir = Resolve-Path $Dir

Get-ChildItem $Dir "$App.json" | ForEach-Object {
if ($PSVersionTable.PSVersion.Major -gt 5) { $_ = $_.Name } # Fix for pwsh
foreach ($m in Get-ChildItem $Dir "$App.json") {
$path = $m.Fullname

# beautify
$json = parse_json "$Dir\$_" | ConvertToPrettyJson
$manifest = parse_json $path | ConvertToPrettyJson

# convert to 4 spaces
$json = $json -replace "`t", ' '
[System.IO.File]::WriteAllLines("$Dir\$_", $json)
# Convert to 4 spaces
$json = $json -replace "`t", (4 * ' ')
[System.IO.File]::WriteAllLines($path, $manifest)
}

0 comments on commit d72ee12

Please sign in to comment.