-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.ps1
44 lines (36 loc) · 1.34 KB
/
install.ps1
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
#!/usr/bin/env pwsh
# Keep this script simple and easily auditable!
$ErrorActionPreference = 'Stop'
if ($v) {
$Version = "${v}"
}
if ($Args.Length -eq 1) {
$Version = $Args.Get(0)
}
$TypstInstall = $env:TYPST_INSTALL
if (!$TypstInstall) {
$TypstInstall = "${Home}\.typst"
}
$Target = 'x86_64-pc-windows-msvc'
$Folder = "typst-${Target}"
$File = "$Folder.zip"
$URL = if ($Version) {
"https://github.com/typst/typst/releases/download/v${Version}/$File"
} else {
"https://github.com/typst/typst/releases/latest/download/$File"
}
if (!(Test-Path "$TypstInstall")) {
New-Item "$TypstInstall" -ItemType Directory | Out-Null
}
curl.exe -fsSL "$URL" -o "$TypstInstall\$File"
tar.exe -xf "$TypstInstall\$File" -C "$TypstInstall"
Remove-Item "$TypstInstall\$File"
$User = [System.EnvironmentVariableTarget]::User
$Path = [System.Environment]::GetEnvironmentVariable('Path', $User)
if (!(";${Path};".ToLower() -like "*;$TypstInstall\$Folder;*".ToLower())) {
[System.Environment]::SetEnvironmentVariable('Path', "${Path};$TypstInstall\$Folder", $User)
$Env:Path += ";$TypstInstall\$Folder"
}
Write-Output "Typst was installed successfully to $TypstInstall\$Folder\typst.exe"
Write-Output "Run 'typst --help' to get started"
Write-Output "Stuck? Open an Issue https://github.com/typst-community/typst-install/issues"