Skip to content

Commit

Permalink
Sort the keys in devDependencies and overrides (Azure#35666)
Browse files Browse the repository at this point in the history
Co-authored-by: Patrick Hallisey <[email protected]>
  • Loading branch information
azure-sdk and hallipr authored May 17, 2024
1 parent f92b18d commit 25ac3de
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions eng/common/scripts/typespec/New-EmitterPackageJson.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,24 @@ param (
$packageJson = Get-Content $PackageJsonPath | ConvertFrom-Json -AsHashtable

# If we provide OverridesPath, use that to load a hashtable of version overrides
$overrides = @{}
$overrides = [ordered]@{}

if ($OverridesPath) {
Write-Host "Using overrides from $OverridesPath`:`n"
$overrides = Get-Content $OverridesPath | ConvertFrom-Json -AsHashtable
$overridesJson = Get-Content $OverridesPath | ConvertFrom-Json -AsHashtable
foreach ($key in $overridesJson.Keys | Sort-Object) {
$overrides[$key] = $overridesJson[$key]
}
Write-Host ($overrides | ConvertTo-Json)
Write-Host ""
}


# If there's a peer dependency and a dev dependency for the same package, carry the
# dev dependency forward into emitter-package.json

$devDependencies = @{}
$devDependencies = [ordered]@{}

foreach ($package in $packageJson.peerDependencies.Keys) {
foreach ($package in $packageJson.peerDependencies.Keys | Sort-Object) {
$pinnedVersion = $packageJson.devDependencies[$package]
if ($pinnedVersion -and -not $overrides[$package]) {
Write-Host "Pinning $package to $pinnedVersion"
Expand Down

0 comments on commit 25ac3de

Please sign in to comment.