Skip to content

Commit 692c6f9

Browse files
committed
No more write-host for Install-UnitySetupInstance
1 parent 43386b8 commit 692c6f9

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

UnitySetup/UnitySetup.psm1

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ function Find-UnitySetupInstaller {
317317
#>
318318
function Install-UnitySetupInstance {
319319
[CmdletBinding()]
320-
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingWriteHost', '', Scope = 'Function')]
321320
param(
322321
[parameter(ValueFromPipeline = $true)]
323322
[UnitySetupInstaller[]] $Installers,
@@ -379,34 +378,31 @@ function Install-UnitySetupInstance {
379378
Start-BitsTransfer -Source $downloadSource -Destination $downloadDest
380379
}
381380

382-
$spins = @('|', '/', '-', '\')
383381
for ($i = 0; $i -lt $localInstallers.Length; $i++) {
384382
$installer = $localInstallers[$i]
385383
$destination = $localDestinations[$i]
386384

387385
$startProcessArgs = @{
388386
'FilePath' = $installer;
389-
'ArgumentList' = @("/S", "/D=$($localDestinations[$i])");
387+
'ArgumentList' = @("/S", "/D=$destination");
390388
'PassThru' = $true;
391389
}
392390

393391
if ($Verb) {
394392
$startProcessArgs['Verb'] = $Verb
395393
}
396394

397-
$spinnerIndex = 0
395+
Write-Verbose "$(Get-Date): Installing $installer to $destination."
398396
$process = Start-Process @startProcessArgs
399-
while (!$process.HasExited) {
400-
Write-Host "`rInstalling $installer to $destination - $($spins[$spinnerIndex++ % $spins.Length])" -NoNewline
401-
Start-Sleep -Milliseconds 100
402-
}
397+
if( $process ) {
398+
$process.WaitForExit()
403399

404-
if ( $process.ExitCode -ne 0) {
405-
Write-Host "`bFailed."
406-
Write-Error "Installing $installer failed with exit code: $($process.ExitCode)"
407-
}
408-
else {
409-
Write-Host "`bSucceeded."
400+
if ( $process.ExitCode -ne 0) {
401+
Write-Error "$(Get-Date): Failed with exit code: $($process.ExitCode)"
402+
}
403+
else {
404+
Write-Verbose "$(Get-Date): Succeeded."
405+
}
410406
}
411407
}
412408
}
@@ -816,11 +812,11 @@ function Start-UnityEditor {
816812
) | ForEach-Object {
817813

818814
$alias = Get-Alias -Name $_.Name -ErrorAction 'SilentlyContinue'
819-
if( -not $alias ) {
815+
if ( -not $alias ) {
820816
Write-Verbose "Creating new alias $($_.Name) for $($_.Value)"
821817
New-Alias @_
822818
}
823-
elseif( $alias.ModuleName -eq 'UnitySetup' ) {
819+
elseif ( $alias.ModuleName -eq 'UnitySetup' ) {
824820
Write-Verbose "Setting alias $($_.Name) to $($_.Value)"
825821
Set-Alias @_
826822
}

0 commit comments

Comments
 (0)