From 30e9ef1dff622f42c2bcf4c752696ee152a780b1 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 18 Apr 2019 11:26:36 -0700 Subject: [PATCH 1/6] crossplat install.ps1 --- install.ps1 | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/install.ps1 b/install.ps1 index dc94f14d6..5b0e671ba 100644 --- a/install.ps1 +++ b/install.ps1 @@ -1,19 +1,35 @@ +#!/usr/bin/env pwsh + $version = '0.1.145' $name = 'languageclient' $url = "https://github.com/autozimu/LanguageClient-neovim/releases/download/$version/$name-$version-" -if ($ENV:PROCESSOR_ARCHITECTURE -eq 'AMD64') { +if ([Environment]::Is64BitOperatingSystem) { $url += 'x86_64' } else { $url += 'i686' } -$url += '-pc-windows-gnu.exe' +$path = "$PSScriptRoot\bin\$name" +$url += switch ($true) { + $IsMacOS { "-apple-darwin" } + $IsLinux { "-unknown-linux-musl" } + Default { + # Windows + $path += ".exe" + return "-pc-windows-gnu.exe" + } +} -$path = "$PSScriptRoot\bin\$name.exe" -if (Test-Path $path) { - Remove-Item -Force $path +if (Test-Path -LiteralPath $path) { + Remove-Item -Force -LiteralPath $path } + echo "Downloading $url ..." -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + +if(!$IsCoreCLR) { + # We only need to do this for Windows PowerShell + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 +} + Invoke-WebRequest -Uri $url -OutFile $path From bbf1bcc44d1288788d2e87782d4fb95a3c6a80c0 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 18 Apr 2019 11:36:15 -0700 Subject: [PATCH 2/6] remove return --- install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index 5b0e671ba..bf3b50b61 100644 --- a/install.ps1 +++ b/install.ps1 @@ -17,7 +17,7 @@ $url += switch ($true) { Default { # Windows $path += ".exe" - return "-pc-windows-gnu.exe" + "-pc-windows-gnu.exe" } } From 194af7b908bc02c9555652ce4b6867a5d9a08d84 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 18 Apr 2019 11:43:35 -0700 Subject: [PATCH 3/6] chmod +x install.ps1 --- install.ps1 | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 install.ps1 diff --git a/install.ps1 b/install.ps1 old mode 100644 new mode 100755 From 4a22b3d022634b3ec6eea2fd2616b2862e72ede1 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 18 Apr 2019 12:01:47 -0700 Subject: [PATCH 4/6] handle ARM --- install.ps1 | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/install.ps1 b/install.ps1 index bf3b50b61..44c55d6de 100755 --- a/install.ps1 +++ b/install.ps1 @@ -4,20 +4,32 @@ $version = '0.1.145' $name = 'languageclient' $url = "https://github.com/autozimu/LanguageClient-neovim/releases/download/$version/$name-$version-" -if ([Environment]::Is64BitOperatingSystem) { - $url += 'x86_64' +# Set architecture +if(!$IsLinux) { + $url += if ([Environment]::Is64BitOperatingSystem) { + 'x86_64' + } else { + 'i686' + } } else { - $url += 'i686' + # Detecting architecture is more involved on Linux + $arch = uname -sm + $url += switch ($arch) { + 'Linux x86_64' { 'x86_64' } + 'Linux i686' { 'i686' } + 'Linux aarch64' { 'aarch64' } + Default { throw 'architecture not supported' } + } } $path = "$PSScriptRoot\bin\$name" $url += switch ($true) { - $IsMacOS { "-apple-darwin" } - $IsLinux { "-unknown-linux-musl" } + $IsMacOS { '-apple-darwin' } + $IsLinux { '-unknown-linux-musl' } Default { # Windows - $path += ".exe" - "-pc-windows-gnu.exe" + $path += '.exe' + '-pc-windows-gnu.exe' } } From c801bf7176f7af86db93d88ae8c5f4f84272252d Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 18 Apr 2019 12:06:47 -0700 Subject: [PATCH 5/6] switch to 1 switch --- install.ps1 | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/install.ps1 b/install.ps1 index 44c55d6de..f9e14a817 100755 --- a/install.ps1 +++ b/install.ps1 @@ -4,32 +4,31 @@ $version = '0.1.145' $name = 'languageclient' $url = "https://github.com/autozimu/LanguageClient-neovim/releases/download/$version/$name-$version-" -# Set architecture -if(!$IsLinux) { - $url += if ([Environment]::Is64BitOperatingSystem) { - 'x86_64' - } else { - 'i686' +$path = "$PSScriptRoot\bin\$name" + +switch ($true) { + $IsMacOS { + # MacOS is always x86_64 + $url += 'x86_64-apple-darwin' } -} else { - # Detecting architecture is more involved on Linux - $arch = uname -sm - $url += switch ($arch) { - 'Linux x86_64' { 'x86_64' } - 'Linux i686' { 'i686' } - 'Linux aarch64' { 'aarch64' } - Default { throw 'architecture not supported' } + $IsLinux { + # Detecting architecture is more involved on Linux + $arch = uname -sm + $url += switch ($arch) { + 'Linux x86_64' { 'x86_64' } + 'Linux i686' { 'i686' } + 'Linux aarch64' { 'aarch64' } + Default { throw 'architecture not supported' } + } + $url += '-unknown-linux-musl' } -} - -$path = "$PSScriptRoot\bin\$name" -$url += switch ($true) { - $IsMacOS { '-apple-darwin' } - $IsLinux { '-unknown-linux-musl' } Default { # Windows + $url += if ([Environment]::Is64BitOperatingSystem) { 'x86_64' } else { 'i686' } + $url += '-pc-windows-gnu.exe' + + # We need to tack on the .exe to the end of the download path $path += '.exe' - '-pc-windows-gnu.exe' } } From ed101f67546b7b74ad07e6482ed8bc12781b11c3 Mon Sep 17 00:00:00 2001 From: Junfeng Li Date: Thu, 18 Apr 2019 15:27:54 -0700 Subject: [PATCH 6/6] Space. --- install.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.ps1 b/install.ps1 index f9e14a817..fc2cfcb4a 100755 --- a/install.ps1 +++ b/install.ps1 @@ -38,7 +38,7 @@ if (Test-Path -LiteralPath $path) { echo "Downloading $url ..." -if(!$IsCoreCLR) { +if (!$IsCoreCLR) { # We only need to do this for Windows PowerShell [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 }