Skip to content

Instantly share code, notes, and snippets.

@holtsoftware
Last active December 13, 2019 22:35
Show Gist options
  • Save holtsoftware/da51a2fd555f987e7ec68bcc9ff4f551 to your computer and use it in GitHub Desktop.
Save holtsoftware/da51a2fd555f987e7ec68bcc9ff4f551 to your computer and use it in GitHub Desktop.
Script to sync unicorn configs based on dependencies
[System.Collections.ArrayList]$configs = Get-UnicornConfiguration
[System.Collections.ArrayList]$synced = @()
[System.Collections.ArrayList]$toRemove = @()
$totalCount=0
while($configs.Length -gt 0)
{
$totalCount++
if($totalCount -gt 100)
{
break
}
foreach($c in $configs)
{
if($c.Dependencies.Length -eq 0)
{
Write-Host "No Dependencies in $($c.Name)"
$c | Sync-UnicornConfiguration
$toRemove.Add($c);
$synced.Add($c.Name);
}
else
{
$countSynced = 0
foreach($d in $c.Dependencies)
{
if($synced.Contains($d))
{
$countSynced++
}
}
if($c.Dependencies.Length -eq $countSynced)
{
Write-Host "Dependencies Synced. Syncing in $($c.Name)"
$c | Sync-UnicornConfiguration
$toRemove.Add($c);
$synced.Add($c.Name);
}
}
}
foreach($r in $toRemove)
{
$configs.Remove($r)
}
$toRemove.Clear()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment