Skip to content

Commit 9fa4c8b

Browse files
authored
Merge pull request #82 from jwittner/fix/aliasReimportFailure
Improve alias handling
2 parents 047af9c + 17a8ad5 commit 9fa4c8b

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,23 @@ function Start-UnityEditor {
808808
}
809809
}
810810

811-
New-Alias -Name gusi -Value Get-UnitySetupInstance
812-
New-Alias -Name gupi -Value Get-UnityProjectInstance
813-
New-Alias -Name susi -Value Select-UnitySetupInstance
814-
New-Alias -Name sue -Value Start-UnityEditor
811+
@(
812+
@{ 'Name' = 'gusi'; 'Value' = 'Get-UnitySetupInstance' },
813+
@{ 'Name' = 'gupi'; 'Value' = 'Get-UnityProjectInstance' },
814+
@{ 'Name' = 'susi'; 'Value' = 'Select-UnitySetupInstance' },
815+
@{ 'Name' = 'sue'; 'Value' = 'Start-UnityEditor' }
816+
) | ForEach-Object {
817+
818+
$alias = Get-Alias -Name $_.Name -ErrorAction 'SilentlyContinue'
819+
if( -not $alias ) {
820+
Write-Verbose "Creating new alias $($_.Name) for $($_.Value)"
821+
New-Alias @_
822+
}
823+
elseif( $alias.ModuleName -eq 'UnitySetup' ) {
824+
Write-Verbose "Setting alias $($_.Name) to $($_.Value)"
825+
Set-Alias @_
826+
}
827+
else {
828+
Write-Warning "Alias $($_.Name) already configured by $($alias.Source)"
829+
}
830+
}

0 commit comments

Comments
 (0)