Skip to content

Commit 3d01f1d

Browse files
committed
fix: change to YamlDotNet from FXPSYaml
1 parent 1f01eca commit 3d01f1d

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

src/playbook/Executables/APPLYDUHIVE.ps1

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,37 @@
1-
# Load DefaultUser hive
2-
$module = Get-Module -Name "FXPSYaml"
3-
if (!$module) {
4-
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
5-
Install-Module -Name FXPSYaml -Force
6-
Import-Module -Name FXPSYaml
1+
# Load YamlDotNet for YAML parsing
2+
# YamlDotNet by Antoine Aubry - https://github.com/aaubry/YamlDotNet (MIT License)
3+
Add-Type -Path "$PSScriptRoot\YamlDotNet.dll"
4+
5+
function ConvertFrom-Yaml {
6+
param([string]$YamlString)
7+
$reader = New-Object System.IO.StringReader($YamlString)
8+
$yamlStream = New-Object YamlDotNet.RepresentationModel.YamlStream
9+
$yamlStream.Load($reader)
10+
$reader.Close()
11+
12+
function ConvertNode($node) {
13+
if ($node -is [YamlDotNet.RepresentationModel.YamlMappingNode]) {
14+
$ht = @{}
15+
foreach ($pair in $node.Children) {
16+
$ht[$pair.Key.Value] = ConvertNode $pair.Value
17+
}
18+
return $ht
19+
}
20+
elseif ($node -is [YamlDotNet.RepresentationModel.YamlSequenceNode]) {
21+
$arr = @()
22+
foreach ($item in $node.Children) {
23+
$arr += ConvertNode $item
24+
}
25+
return $arr
26+
}
27+
else {
28+
return $node.Value
29+
}
30+
}
31+
32+
return ConvertNode $yamlStream.Documents[0].RootNode
733
}
34+
835
$configurationFolder = Join-Path $PSScriptRoot "..\Configuration\tweaks"
936
$yamlFiles = Get-ChildItem -Path $configurationFolder -Filter *.yml -Recurse
1037
$RegistryPaths = @()
@@ -39,4 +66,4 @@ foreach ($path in $RegistryPaths) {
3966
}
4067
}
4168
}
42-
}
69+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[InternetShortcut]
2+
URL=https://github.com/aaubry/YamlDotNet
264 KB
Binary file not shown.

0 commit comments

Comments
 (0)