Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install PowerShell Script #66

Merged
merged 1 commit into from
Jan 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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."
Loading