Skip to content

Commit

Permalink
Update on existing metadata json file. (#24477)
Browse files Browse the repository at this point in the history
Co-authored-by: Sima Zhu <[email protected]>
  • Loading branch information
azure-sdk and sima-zhu authored Jan 13, 2023
1 parent 0523409 commit 4995b85
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions eng/common/scripts/Update-DocsMsMetadata.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ param(
[Parameter(Mandatory = $true)]
[string]$DocRepoLocation,

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[string]$Language,

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[string]$RepoId,

[Parameter(Mandatory = $false)]
Expand Down Expand Up @@ -192,8 +192,20 @@ function UpdateDocsMsMetadataForPackage($packageInfoJsonLocation) {
}
$packageMetadataName = Split-Path $packageInfoJsonLocation -Leaf
$packageInfoLocation = Join-Path $DocRepoLocation "metadata/$metadataMoniker"
if (Test-Path "$packageInfoLocation/$packageMetadataName") {
Write-Host "The docs metadata json $packageMetadataName exists, updating..."
$docsMetadata = Get-Content "$packageInfoLocation/$packageMetadataName" -Raw | ConvertFrom-Json
foreach ($property in $docsMetadata.PSObject.Properties) {
if ($packageInfo.PSObject.Properties.Name -notcontains $property.Name) {
$packageInfo | Add-Member -MemberType $property.MemberType -Name $property.Name -Value $property.Value -Force
}
}
}
else {
Write-Host "The docs metadata json $packageMetadataName does not exist, creating a new one to docs repo..."
New-Item -ItemType Directory -Path $packageInfoLocation -Force
}
$packageInfoJson = ConvertTo-Json $packageInfo
New-Item -ItemType Directory -Path $packageInfoLocation -Force
Set-Content `
-Path $packageInfoLocation/$packageMetadataName `
-Value $packageInfoJson
Expand Down

0 comments on commit 4995b85

Please sign in to comment.