diff --git a/base.ps1 b/base.ps1 index 9cdb393..3773484 100644 --- a/base.ps1 +++ b/base.ps1 @@ -2,19 +2,14 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,21 +73,6 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } @@ -206,18 +186,8 @@ function Install-WinUtilWinget { Write-Output "Refreshing Environment Variables...`n" $ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") } Catch { - Write-Host "Failure detected while installing via GitHub method. Continuing with Chocolatey method as fallback." -ForegroundColor Red - # In case install fails via GitHub method. - Try { - # Install Choco if not already present - Install-WinUtilChoco - Start-Process -Verb runas -FilePath powershell.exe -ArgumentList "choco install winget-cli" - Write-Host "Winget Installed" -ForegroundColor Green - Write-Output "Refreshing Environment Variables...`n" - $ENV:PATH = [System.Environment]::GetEnvironmentVariable("Path", "Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path", "User") - } Catch { - throw [WingetFailedInstall]::new('Failed to install!') - } + Write-Host "Failure detected while installing via GitHub method. Your computer cannot run winget. Please email help@learncodethehardway.com to help find out why." -ForegroundColor Red + throw [WingetFailedInstall]::new('Failed to install!') } } @@ -235,7 +205,10 @@ if(-not $isAdmin) { ) } - Write-Warning "About to install winget" + Write-Warning "About to install winget. Winget is a Microsoft open source package manager." + Write-Warning "To install Winget this script will temporarily launch in Administrator mode, then get out of it." + Write-Warning "If you already have Winget then this will only check that you have it, or upgrade it." + Write-Warning "If you'd prefer to not use it then abort now and good luck getting everything installed." Read-Host -Prompt "Press any key to continue, or CTRL-C to abort" | Out-Null @@ -256,14 +229,11 @@ $installs=@( 'Microsoft.VCRedist.2015+.x64' ) -$choco_installs=@() - Write-Warning "About to install the following software:" Write-Warning "-----------------------------------------" foreach($pkg in $installs) { Write-Host $pkg } -foreach($pkg in $choco_installs) { Write-Host $pkg } Write-Warning "-----------------------------------------" -Write-Warning "This will use winget and chocolatey to do the installs." +Write-Warning "This will use winget to do the installs. If you already have this software installed then winget should only upgrade them. If you don't want this then abort now." Read-Host -Prompt "Press any key to continue, or CTRL-C to abort" | Out-Null @@ -271,13 +241,36 @@ foreach($pkg in $installs) { Start-Process -NoNewWindow -Wait winget -ArgumentList 'install',$pkg } -Write-Warning "!! Installing WinLibs in $env:HOMEPATH\WinLibs" +$winlibsPath = "$env:HOMEDRIVE$env:HOMEPATH\WinLibs" + +if(Test-Path -Path $winlibsPath) { + Write-Warning "#=========================================================#" + Write-Warning "!! The directory $winlibsPath already exists, which means" + Write-Warning "!! you already have winlibs installed. Here's the version:" + cat "$winlibsPath\mingw64\version_info.txt" + Write-Warning "#=========================================================#" + Write-Warning "Here's the version that Winget will install:" + winget search BrechtSanders.WinLibs.POSIX.UCRT.LLVM + Write-Warning "--- If you want me to replace your install with this version, then stop and" + Write-Warning "delete the $winlibsPath directory before hitting ENTER to continue." + Write-Warning "!!! If you do NOT want to replace this directory then hit CTRL-C now." + Read-Host -Prompt "Press any key to continue, or CTRL-C to abort" | Out-Null +} + +Write-Warning "!! Installing WinLibs in $winlibsPath" Write-Warning "This has to be installed this way because winget won't add it to the path so I have to do it manually. If you don't want this, then hit CTRL-C and install WinLibs yourself." Read-Host -Prompt "Press any key to continue, or CTRL-C to abort" | Out-Null -winget install --location "$env:HOMEPATH\WinLibs" -e BrechtSanders.WinLibs.POSIX.UCRT.LLVM +winget install --location "$winlibsPath" -e BrechtSanders.WinLibs.POSIX.UCRT.LLVM -$newPath = $Env:PATH + ";$env:HOMEPATH\WinLibs\mingw64\bin" -[Environment]::SetEnvironmentVariable("Path", $newPath, "User") +if($env:PATH.contains($winlibsPath)) { + Write-Warning "!! Detected $winLibsPath in your PATH. Will not update your PATH." + Write-Warning "!! This is probably because you already installed it. You'll have" + Write-Warning "!! to manually remove this part of your path if you want to change it." + Write-Warning "!! But, it will probably still work since that's where I installed it." +} else { + $newPath = $Env:PATH + ";$winlibsPath\mingw64\bin" + [Environment]::SetEnvironmentVariable("Path", $newPath, "User") +} Write-Warning "!!! CLOSE THIS POWERSHELL AND START A NEW ONE TO UPDATE PATH!" diff --git a/bunjs.ps1 b/bunjs.ps1 index cf0f0a1..6c4a5ab 100644 --- a/bunjs.ps1 +++ b/bunjs.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/cpp.ps1 b/cpp.ps1 index 00c955c..b1bc39f 100644 --- a/cpp.ps1 +++ b/cpp.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." @@ -115,4 +94,3 @@ ConfirmBaseRun Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','ezwinports.make' Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','mesonbuild.meson' Start-Process -NoNewWindow -Wait winget -ArgumentList 'install','Kitware.CMake' - diff --git a/crystal.ps1 b/crystal.ps1 index 77765a6..c2b2e08 100644 --- a/crystal.ps1 +++ b/crystal.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/extras.ps1 b/extras.ps1 index fd29cc9..b906476 100644 --- a/extras.ps1 +++ b/extras.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/go.ps1 b/go.ps1 index f9ff137..8512779 100644 --- a/go.ps1 +++ b/go.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/nodejs.ps1 b/nodejs.ps1 index 3716b20..d687aa7 100644 --- a/nodejs.ps1 +++ b/nodejs.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/python.ps1 b/python.ps1 index 0db923a..e625060 100644 --- a/python.ps1 +++ b/python.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/ruby.ps1 b/ruby.ps1 index 6661c3b..e35fb5a 100644 --- a/ruby.ps1 +++ b/ruby.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/rust.ps1 b/rust.ps1 index 587dd92..d689fed 100644 --- a/rust.ps1 +++ b/rust.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more." diff --git a/zig.ps1 b/zig.ps1 index 4e23906..165ac79 100644 --- a/zig.ps1 +++ b/zig.ps1 @@ -2,19 +2,15 @@ function Test-WinUtilPackageManager { <# .SYNOPSIS - Checks if Winget and/or Choco are installed + Checks if Winget is installed .PARAMETER winget Check if Winget is installed - .PARAMETER choco - Check if Chocolatey is installed - #> Param( - [System.Management.Automation.SwitchParameter]$winget, - [System.Management.Automation.SwitchParameter]$choco + [System.Management.Automation.SwitchParameter]$winget ) $status = "not-installed" @@ -78,31 +74,14 @@ function Test-WinUtilPackageManager { } } - if ($choco) { - if ((Get-Command -Name choco -ErrorAction Ignore) -and ($chocoVersion = (Get-Item "$env:ChocolateyInstall\choco.exe" -ErrorAction Ignore).VersionInfo.ProductVersion)) { - Write-Host "===========================================" -ForegroundColor Green - Write-Host "--- Chocolatey is installed ---" -ForegroundColor Green - Write-Host "===========================================" -ForegroundColor Green - Write-Host "Version: v$chocoVersion" -ForegroundColor White - $status = "installed" - } else { - Write-Host "===========================================" -ForegroundColor Red - Write-Host "--- Chocolatey is not installed ---" -ForegroundColor Red - Write-Host "===========================================" -ForegroundColor Red - $status = "not-installed" - } - } - return $status } function ConfirmBaseRun { $isWingetInstalled = Test-WinUtilPackageManager -winget - $isChocoInstalled = Test-WinUtilPackageManager -choco - if (!($isWingetInstalled -eq "installed") -or - !($isChocoInstalled -eq "installed")) { - Write-Warning "!!! Either winget or choco is not installed." + if (!($isWingetInstalled -eq "installed")) { + Write-Warning "!!! Winget is not installed." Write-Host "You haven't run the base.ps1 script yet. Please visit https://learncodethehardway.com/setup/installers.html for more."