Skip to content

Commit

Permalink
Merge pull request #29 from regg00/27-show-progress-on-installation
Browse files Browse the repository at this point in the history
commands in job and spinner output
  • Loading branch information
regg00 authored Aug 16, 2023
2 parents 81d168b + 8130726 commit 6dca521
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions Private/Invoke-ChocoCommand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,27 @@ Function Invoke-ChocoCommand {
$Arguments += "-r"
$Arguments += "--no-color"

$ChocoCommand = @(Get-Command 'choco.exe' -CommandType 'Application' -ErrorAction 'SilentlyContinue')[0]
Write-Verbose "Command to execute: choco $($Arguments -join ' ')"
$Output = (&$ChocoCommand $Arguments)

$Job = Start-Job { choco $args } -ArgumentList $Arguments

$Symbols = @("⣾⣿", "⣽⣿", "⣻⣿", "⢿⣿", "⡿⣿", "⣟⣿", "⣯⣿", "⣷⣿",
"⣿⣾", "⣿⣽", "⣿⣻", "⣿⢿", "⣿⡿", "⣿⣟", "⣿⣯", "⣿⣷")

$i = 0;
while ($Job.State -eq "Running") {
$symbol = $symbols[$i]
Write-Host -NoNewLine "`r$symbol $Label" -ForegroundColor Green
Start-Sleep -Milliseconds 100
$i++
if ($i -eq $symbols.Count) {
$i = 0;
}
}
Write-Host -NoNewLine "`r"


$Output = Receive-Job $Job

if ($LASTEXITCODE -eq 1 -or $LASTEXITCODE -eq -1) {
$Status = "Error"
Expand Down

0 comments on commit 6dca521

Please sign in to comment.