From 4b6deda40acdf2d21d0d89310d4ca81a75198cea Mon Sep 17 00:00:00 2001 From: Billie Thompson Date: Thu, 31 Oct 2024 19:04:18 +0100 Subject: [PATCH] fix: correct windows install --- installer.ps1 | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/installer.ps1 b/installer.ps1 index 7e223e33..e22398fb 100644 --- a/installer.ps1 +++ b/installer.ps1 @@ -1,21 +1,17 @@ # git-mit installer script for Windows -# Create temporary directory -$TmpDir = New-TemporaryDirectory -Set-Location $TmpDir - # Define architecture $Arch = "x86_64-pc-windows-msvc.exe" # Define binaries to download -$Binaries = @("git-mit", "git-mit-config", "git-mit-install", "git-mit-relates-to", - "mit-commit-msg", "mit-pre-commit", "mit-prepare-commit-msg") +$Binaries = @("git-mit", "git-mit-config", "git-mit-install", "git-mit-relates-to", "mit-commit-msg", "mit-pre-commit", "mit-prepare-commit-msg") # Create install directory if it doesn't exist $InstallDir = "$env:USERPROFILE\git-mit" New-Item -ItemType Directory -Force -Path $InstallDir | Out-Null -foreach ($Binary in $Binaries) { +foreach ($Binary in $Binaries) +{ Write-Host "📥 Downloading $Binary..." $BinaryUrl = "https://github.com/PurpleBooth/git-mit/releases/latest/download/${Binary}-${Arch}" $HashUrl = "${BinaryUrl}.sha256" @@ -28,10 +24,13 @@ foreach ($Binary in $Binaries) { $ExpectedHash = Get-Content "$Binary.sha256" -Raw $ActualHash = (Get-FileHash "$Binary.exe" -Algorithm SHA256).Hash.ToLower() - if ($ActualHash -eq $ExpectedHash.Split()[0].ToLower()) { + if ($ActualHash -eq $ExpectedHash.Split()[0].ToLower()) + { Write-Host "✅ Verified $Binary" Move-Item "$Binary.exe" "$InstallDir" -Force - } else { + } + else + { Write-Host "❌ Verification failed for $Binary" exit 1 } @@ -39,11 +38,11 @@ foreach ($Binary in $Binaries) { # Add to PATH if not already present $UserPath = [Environment]::GetEnvironmentVariable("Path", "User") -if ($UserPath -notlike "*$InstallDir*") { +if ($UserPath -notlike "*$InstallDir*") +{ [Environment]::SetEnvironmentVariable("Path", "$UserPath;$InstallDir", "User") } Set-Location - -Remove-Item $TmpDir -Recurse -Force Write-Host "🎉 Installation complete! Please restart your terminal and run 'git mit-install' to set up your repository."