Skip to content

Commit 1787858

Browse files
author
James Brundage
committed
Updating YAML Formatter (Fixes #180)
1 parent 3695b3a commit 1787858

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Formatting/YAML.format.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
Write-FormatView -Typename YAML -Action {
2-
Format-YAML -inputObject $_
2+
$inputObject = $_
3+
if ($inputObject.psobject.properties['Indent'].Value -as [int]) {
4+
$indentLevel = $inputObject.Indent -as [int]
5+
$inputCopy = [Ordered]@{}
6+
foreach ($prop in $inputObject.psobject.properties) {
7+
if ($prop.Name -eq 'indent') { continue }
8+
$inputCopy[$prop.Name] = $prop.Value
9+
}
10+
Format-YAML -inputObject $inputCopy -Indent $indentLevel
11+
} else {
12+
Format-YAML -inputObject $inputObject
13+
}
14+
315
}

0 commit comments

Comments
 (0)