Skip to content

Commit

Permalink
fix: correct windows install
Browse files Browse the repository at this point in the history
  • Loading branch information
PurpleBooth committed Oct 31, 2024
1 parent 27ca1d5 commit 4b6deda
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions installer.ps1
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -28,22 +24,25 @@ 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
}
}

# 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."

0 comments on commit 4b6deda

Please sign in to comment.