-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f735753
commit f000888
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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." |