Skip to content

Commit

Permalink
Install PowerShell Script (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
garrettladley authored Jan 26, 2024
1 parent f735753 commit f000888
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Get the absolute path to the current script
$ScriptPath = (Get-Item -Path $MyInvocation.MyCommand.Path).DirectoryName

# Build the Go CLI tool
go build -o "sac-cli" "cli/main.go"

# Check if sac-cli is already installed
if (Test-Path -Path "$Env:USERPROFILE\AppData\Local\Programs\sac-cli\sac-cli.exe") {
Write-Host "sac-cli is already installed."
exit 1
}

# Copy the sac-cli executable to a directory in the user's PATH
$InstallPath = "$Env:USERPROFILE\AppData\Local\Programs\sac-cli"
if (-not (Test-Path -Path $InstallPath)) {
New-Item -ItemType Directory -Path $InstallPath | Out-Null
}
Copy-Item -Path "sac-cli" -Destination "$InstallPath\sac-cli.exe" -Force

# Add the installation path to the user's PATH
$PathEnvVar = [System.Environment]::GetEnvironmentVariable("PATH", [System.EnvironmentVariableTarget]::User)
if (-not ($PathEnvVar -like "*$InstallPath*")) {
[System.Environment]::SetEnvironmentVariable("PATH", "$InstallPath;$PathEnvVar", [System.EnvironmentVariableTarget]::User)
}

# Inform the user
Write-Host "Installation complete. You can now run 'sac-cli' from anywhere."

0 comments on commit f000888

Please sign in to comment.