Update on existing metadata json file. (#4247)
Co-authored-by: Sima Zhu <sizhu@microsoft.com>
This commit is contained in:
parent
275f6f8077
commit
90a4316ae5
@ -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)]
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user