Repository navigation
Expand file tree
/
Copy pathinstall.ps1
More file actions
57 lines (51 loc) · 2.42 KB
/
Copy pathinstall.ps1
File metadata and controls
57 lines (51 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Builds TermDevTools for Windows and installs the binary — all there is to
# install: its reference data and recipes are built in.
#
# Run from anywhere; it locates the repository from its own path. Override
# the install location with $env:TERMDEVTOOLS_INSTALL_DIR if the default
# doesn't suit you.
$ErrorActionPreference = "Stop"
Set-Location $PSScriptRoot
$installDir = if ($env:TERMDEVTOOLS_INSTALL_DIR) { $env:TERMDEVTOOLS_INSTALL_DIR } else { "$env:LOCALAPPDATA\termdevtools" }
New-Item -ItemType Directory -Force -Path $installDir | Out-Null
# What "termdevtools --version" will answer: the tag of the checkout, or how
# far past it this build is.
$version = "dev"
try {
$described = git describe --tags --always --dirty 2>$null
if ($LASTEXITCODE -eq 0 -and $described) { $version = $described }
} catch {}
Write-Host "Building termdevtools $version into $installDir ..."
$env:CGO_ENABLED = "0"
go build -trimpath -ldflags "-X main.version=$version" -o "$installDir\termdevtools.exe" .
if ($LASTEXITCODE -ne 0) { throw "go build failed" }
Write-Host ""
Write-Host "Installed to: $installDir"
# Versions up to 0.5 installed companion files next to the binary. Nothing is
# deleted here: endpoints.txt and cheatsheet.txt are still read, as the
# team's own additions (SPEC.md §9.1), and may have been customized. Up to
# 0.6, Ctrl+S on a result exported to an "exports" directory there too;
# exports now go to the user's configuration directory.
$legacy = [ordered]@{
"cat_columns.txt" = "no longer read, can be deleted"
"endpoints.txt" = "now built in; keep it only if you added endpoints of your own to it"
"cheatsheet.txt" = "still the editor's starting content; delete it to get the built-in one"
"exports" = "no longer written to; exports now go to your configuration directory"
}
foreach ($name in $legacy.Keys) {
if (Test-Path "$installDir\$name") {
Write-Host "Left over from an earlier version: $installDir\$name ($($legacy[$name]))"
}
}
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")
if ($userPath -notlike "*$installDir*") {
Write-Host ""
Write-Host "$installDir is not on your PATH yet. To add it for your user account, run:"
Write-Host " [Environment]::SetEnvironmentVariable('Path', `$env:Path + ';$installDir', 'User')"
Write-Host "(then open a new terminal)"
Write-Host ""
Write-Host "Or just run it directly: $installDir\termdevtools.exe"
} else {
Write-Host ""
Write-Host "Run: termdevtools.exe"
}