Skip to content

Commit 3e182e7

Browse files
TylerLeonhardtautozimu
authored andcommitted
Cross platform PowerShell install script (#794)
* crossplat install.ps1 * remove return * chmod +x install.ps1 * handle ARM * switch to 1 switch * Space.
1 parent a24a161 commit 3e182e7

File tree

1 file changed

+37
-10
lines changed

1 file changed

+37
-10
lines changed

install.ps1

100644100755
Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,46 @@
1+
#!/usr/bin/env pwsh
2+
13
$version = '0.1.145'
24
$name = 'languageclient'
35
$url = "https://github.com/autozimu/LanguageClient-neovim/releases/download/$version/$name-$version-"
46

5-
if ($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64') {
6-
$url += 'x86_64'
7-
} else {
8-
$url += 'i686'
9-
}
7+
$path = "$PSScriptRoot\bin\$name"
108

11-
$url += '-pc-windows-gnu.exe'
9+
switch ($true) {
10+
$IsMacOS {
11+
# MacOS is always x86_64
12+
$url += 'x86_64-apple-darwin'
13+
}
14+
$IsLinux {
15+
# Detecting architecture is more involved on Linux
16+
$arch = uname -sm
17+
$url += switch ($arch) {
18+
'Linux x86_64' { 'x86_64' }
19+
'Linux i686' { 'i686' }
20+
'Linux aarch64' { 'aarch64' }
21+
Default { throw 'architecture not supported' }
22+
}
23+
$url += '-unknown-linux-musl'
24+
}
25+
Default {
26+
# Windows
27+
$url += if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' }
28+
$url += '-pc-windows-gnu.exe'
29+
30+
# We need to tack on the .exe to the end of the download path
31+
$path += '.exe'
32+
}
33+
}
1234

13-
$path = "$PSScriptRoot\bin\$name.exe"
14-
if (Test-Path $path) {
15-
Remove-Item -Force $path
35+
if (Test-Path -LiteralPath $path) {
36+
Remove-Item -Force -LiteralPath $path
1637
}
38+
1739
echo "Downloading $url ..."
18-
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
40+
41+
if (!$IsCoreCLR) {
42+
# We only need to do this for Windows PowerShell
43+
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
44+
}
45+
1946
Invoke-WebRequest -Uri $url -OutFile $path

0 commit comments

Comments
 (0)