Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
fix a few typos in the fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman committed Jul 21, 2021
1 parent 70d37b4 commit 5ac0c94
Showing 1 changed file with 26 additions and 21 deletions.
47 changes: 26 additions & 21 deletions main.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,36 @@ if ($build -eq "10.0.10240") {
Exit
} elseif ($build -eq "10.0.17134") {
Write-Warning "Your Windows Version is too old to run Winget. Using Chocolatey"
InstallChoco
$global:pkgmgr = "choco"
Read-Host "Press enter to continue"
Clear-Host
} else {
try {
$global:pkgmgr = "winget"
}

$conflocation = "$env:APPDATA\WindowsToolbox\"
if (!(Test-Path -Path $conflocation)) {
$JSONData = @{
pkgmgr = "$global:pkgmgr"
}
New-Item -ItemType directory -Path $conflocation | Out-Null
New-Item -Path $conflocation -Name "config.json" -ItemType "file" | Out-Null
$JSONData | ConvertTo-Json | Add-Content -Path "$conflocation\config.json" | Out-Null
} else {
$JSONData = Get-Content -Path "$conflocation\config.json" -Raw | ConvertFrom-Json
$global:pkgmgr = $JSONData.pkgmgr
}

if ($global:pkgmgr -eq "choco") {
$global:notpkgmgr = "winget"
} else {
$global:notpkgmgr = "choco"
}

if ($global:pkgmgr -eq "choco") {
InstallChoco
} else {
try {
# Check if winget is already installed
$er = (invoke-expression "winget -v") 2>&1
if ($lastexitcode) { throw $er }
Expand All @@ -84,25 +108,6 @@ if ($build -eq "10.0.10240") {
Read-Host "Press enter to continue"
Clear-Host
}
$global:pkgmgr = "winget"
}

if (!(Test-Path -Path "$env:APPDATA\WindowsToolbox\config.json")) {
$JSONData = @{
pkgmgr = "$global:pkgmgr"
}
New-Item -ItemType directory -Path "$env:APPDATA\WindowsToolbox\" | Out-Null
New-Item -Path "$env:APPDATA\WindowsToolbox\" -Name "config.json" -ItemType "file" | Out-Null
$JSONData | ConvertTo-Json | Add-Content -Path "$env:APPDATA\WindowsToolbox\config.json" | Out-Null
} else {
$JSONData = Get-Content -Path "$env:APPDATA\WindowsToolbox\config.json" -Raw | ConvertFrom-Json
$JSONData.pkgmgr = $global:pkgmgr
}

if ($global:pkgmgr -eq "choco") {
$global:notpkgmgr = "winget"
} else {
$global:notpkgmgr = "choco"
}

setup
Expand Down

0 comments on commit 5ac0c94

Please sign in to comment.