39 lines
1.0 KiB
PowerShell
39 lines
1.0 KiB
PowerShell
param(
|
|
[string]$InstallDir = "$HOME\.gsp\bin"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$ToolkitDir = Resolve-Path -LiteralPath (Join-Path $ScriptDir "..")
|
|
$TargetDir = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($InstallDir)
|
|
$TargetExe = Join-Path $TargetDir "gsp.exe"
|
|
|
|
New-Item -ItemType Directory -Force -Path $TargetDir | Out-Null
|
|
|
|
Push-Location $ToolkitDir
|
|
try {
|
|
go build -o $TargetExe .\cmd\gsp
|
|
}
|
|
finally {
|
|
Pop-Location
|
|
}
|
|
|
|
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
|
|
$parts = @()
|
|
if ($userPath) {
|
|
$parts = $userPath -split ";" | Where-Object { $_ -ne "" }
|
|
}
|
|
|
|
if ($parts -notcontains $TargetDir) {
|
|
$newPath = (($parts + $TargetDir) -join ";")
|
|
[Environment]::SetEnvironmentVariable("Path", $newPath, "User")
|
|
Write-Host "Installed gsp to $TargetExe"
|
|
Write-Host "Added $TargetDir to the user PATH. Open a new terminal before running gsp."
|
|
}
|
|
else {
|
|
Write-Host "Installed gsp to $TargetExe"
|
|
}
|
|
|
|
& $TargetExe version
|