Skip to content

Commit b4ab14b

Browse files
committed
remove use of powershell-yaml
1 parent c6a96f7 commit b4ab14b

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

tools/GenerateModules.ps1

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ if (-not $Isolated) {
3232
# Module import.
3333
Import-Module PowerShellGet
3434

35-
# Install Powershell-yaml
36-
if (!(Get-Module -Name powershell-yaml -ListAvailable)) {
37-
Install-Module powershell-yaml -Repository PSGallery -Scope CurrentUser -Force
38-
}
3935

4036
$ScriptRoot = $PSScriptRoot
4137
$ModulesSrc = Join-Path $ScriptRoot "..\src\"

tools/ReadModuleReadMe.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ param(
66
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $FieldToRead
77
)
88
$ErrorActionPreference = "Stop"
9+
10+
function ConvertFrom-SimpleYaml {
11+
param([string]$Yaml)
12+
$result = @{}
13+
$Yaml -split "`n" | ForEach-Object {
14+
if ($_.Trim() -match '^([^:]+):\s*(.*)$') {
15+
$result[$Matches[1].Trim()] = $Matches[2].Trim()
16+
}
17+
}
18+
return $result
19+
}
20+
921
$FieldValue = $null
1022
# Read readme.md.
1123
$ReadMeContent = Get-Content $ReadMePath -Delimiter "### Versioning"
1224
if ($ReadMeContent.Length -eq 2) {
1325
# Convert versioning section to yaml.
14-
$VersioningSection = $ReadMeContent[1].Replace("``", "").Replace("yaml", "") | ConvertFrom-Yaml
26+
$VersioningSection = $ReadMeContent[1].Replace("``", "").Replace("yaml", "") | ConvertFrom-SimpleYaml
1527
$FieldValue = $VersioningSection[$FieldToRead]
1628
}
1729
return $FieldValue

tools/WriteToModuleReadMe.ps1

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@ param(
77
[Parameter(Mandatory = $true)][ValidateNotNullOrEmpty()][string] $NewFieldValue
88
)
99
$ErrorActionPreference = "Stop"
10+
11+
function ConvertFrom-SimpleYaml {
12+
param([string]$Yaml)
13+
$result = @{}
14+
$Yaml -split "`n" | ForEach-Object {
15+
if ($_.Trim() -match '^([^:]+):\s*(.*)$') {
16+
$result[$Matches[1].Trim()] = $Matches[2].Trim()
17+
}
18+
}
19+
return $result
20+
}
21+
1022
# Read readme.md.
1123
$ReadMeContent = Get-Content $ReadMePath -Delimiter "### Versioning"
1224
if ($ReadMeContent.Length -eq 2) {
1325
# Convert versioning section to yaml.
1426
$UpdatedVersionSection = "### Versioning" + $ReadMeContent[1]
15-
$VersioningSection = $ReadMeContent[1].Replace("``", "").Replace("yaml", "") | ConvertFrom-Yaml
27+
$VersioningSection = $ReadMeContent[1].Replace("``", "").Replace("yaml", "") | ConvertFrom-SimpleYaml
1628
$FieldValue = $VersioningSection[$FieldName]
1729
$RegexPattern = "$FieldName`:\s*$FieldValue"
1830
$UpdatedVersionSection = $UpdatedVersionSection -replace $RegexPattern, "$FieldName`: $NewFieldValue"

0 commit comments

Comments
 (0)