~james/gengo

gengo/install.ps1 -rw-r--r-- 1.3 KiB
50871857 — james chore(import): snapshot james.dad.town/gengo at 8f775550b0ee 14 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# Create gengo directory in AppData/Roaming
$gengoPath = "$env:APPDATA\gengo"
New-Item -ItemType Directory -Force -Path $gengoPath -ErrorAction SilentlyContinue | Out-Null
Write-Host "Installing gengo to $gengoPath"

# Create and use temporary directory
$tempDir = Join-Path ([System.IO.Path]::GetTempPath()) ([System.IO.Path]::GetRandomFileName())
New-Item -ItemType Directory -Force -Path $tempDir -ErrorAction SilentlyContinue | Out-Null
Push-Location $tempDir

try {
    # Download and extract gengo
    $tempFile = "gengo-installer.tar.gz"
    Invoke-WebRequest -Uri "https://github.com/spenserblack/gengo/releases/latest/download/gengo-x86_64-pc-windows-msvc.tar.gz" -OutFile $tempFile
    tar.exe -xzf $tempFile

    # Move executable to AppData/Roaming/gengo
    Move-Item -Force "gengo.exe" $gengoPath

    # Add to PATH
    $userPath = [Environment]::GetEnvironmentVariable("Path", "User")
    if ($userPath -notlike "*$gengoPath*") {
        [Environment]::SetEnvironmentVariable("Path", "$userPath;$gengoPath", "User")
    }
} finally {
    # Clean up and restore location
    Pop-Location
    Remove-Item -Recurse -Force $tempDir -ErrorAction SilentlyContinue
}

Write-Host "Gengo has been installed and added to your PATH. Please restart your terminal for the changes to take effect."