Skip to content

Commit

Permalink
Revert "Fix powershell script for non-windows users"
Browse files Browse the repository at this point in the history
  • Loading branch information
willcohen committed Nov 21, 2021
1 parent c83236b commit b4351d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 51 deletions.
8 changes: 0 additions & 8 deletions README.md
Expand Up @@ -49,14 +49,6 @@ Make sure to source `jabba.sh` in your environment if you skip it:
export JABBA_VERSION=...
[ -s "$JABBA_HOME/jabba.sh" ] && source "$JABBA_HOME/jabba.sh"
```
> (in powershell)
```powershell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-Expression (
Invoke-WebRequest https://github.com/shyiko/jabba/raw/master/install.ps1 -UseBasicParsing
).Content
```

> In [fish](https://fishshell.com/) command looks a little bit different -
> export JABBA_VERSION=...
Expand Down
50 changes: 7 additions & 43 deletions install.ps1
@@ -1,25 +1,7 @@
$ErrorActionPreference = "Stop"

$sep = [IO.Path]::DirectorySeparatorChar
$jabbaHome = if ($env:JABBA_HOME) {
$env:JABBA_HOME
} else {
if ($env:JABBA_DIR) {
$env:JABBA_DIR
} else {
if($env:USERPROFILE){
"$env:USERPROFILE" + $sep + ".jabba"
}else{
"$env:HOME" + $sep + ".jabba"
}
}
}
$jabbaHome = if ($env:JABBA_HOME) { $env:JABBA_HOME } else { if ($env:JABBA_DIR) { $env:JABBA_DIR } else { "$env:USERPROFILE\.jabba" } }
$jabbaVersion = if ($env:JABBA_VERSION) { $env:JABBA_VERSION } else { "latest" }
# The Windows values of the Platform enum are:
# 0 (Win32NT), 1 (Win32S), 2 (Win32Windows) and 3 (WinCE).
# Other values are larger and indicate non Windows operating systems
$isOnWindows = [System.Environment]::OSVersion.Platform.value__ > 3
$jabbaExecutableName = $isOnWindows ? "jabba.exe" : "jabba"

if ($jabbaVersion -eq "latest")
{
Expand All @@ -43,35 +25,17 @@ if ($env:JABBA_MAKE_INSTALL -eq "true")
}
else
{
# $isOnWindows, see top of the file
# macOS enum value: 6
# Unix enum value: 4
if($isOnWindows){
Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName
}
elseif([System.Environment]::OSVersion.Platform.value__ -eq 4 || [System.Environment]::OSVersion.Platform.value__ -eq 6){
Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-darwin-amd64 -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName
}else{
$osArch = [System.Environment]::Is64BitOperatingSystem ? "amd64" : "386"
Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-linux-${OSARCH} -UseBasicParsing -OutFile $jabbaHome/bin/$jabbaExecutableName
}
Invoke-WebRequest https://github.com/shyiko/jabba/releases/download/$jabbaVersion/jabba-$jabbaVersion-windows-amd64.exe -UseBasicParsing -OutFile $jabbaHome/bin/jabba.exe
}

$ErrorActionPreference="SilentlyContinue"

if($isOnWindows){
& "$jabbaHome\bin\$jabbaExecutableName" --version | Out-Null
}else{
chmod a+x "$jabbaHome/bin/$jabbaExecutableName"
& "$jabbaHome/bin/$jabbaExecutableName" --version | Out-Null
}

& $jabbaHome\bin\jabba.exe --version | Out-Null
$binaryValid = $?
$ErrorActionPreference="Continue"
if (-not $binaryValid)
{
Write-Host -ForegroundColor Yellow @"
$jabbaHome\bin\$jabbaExecutableName does not appear to be a valid binary.
Write-Host @"
$jabbaHome\bin\jabba does not appear to be a valid binary.
Check your Internet connection / proxy settings and try again.
if the problem persists - please create a ticket at https://github.com/shyiko/jabba/issues.
Expand All @@ -85,7 +49,7 @@ if the problem persists - please create a ticket at https://github.com/shyiko/ja
function jabba
{
`$fd3=`$([System.IO.Path]::GetTempFileName())
`$command="& '$jabbaHome\bin\$jabbaExecutableName' `$args --fd3 ```"`$fd3```""
`$command="& '$jabbaHome\bin\jabba.exe' `$args --fd3 ```"`$fd3```""
& { `$env:JABBA_SHELL_INTEGRATION="ON"; Invoke-Expression `$command }
`$fd3content=`$(Get-Content `$fd3)
if (`$fd3content) {
Expand Down Expand Up @@ -117,6 +81,6 @@ else

Write-Host @"
Installation completed (you might need to restart your terminal for the jabba command to be available)
Installation completed
(if you have any problems please report them at https://github.com/shyiko/jabba/issues)
"@

0 comments on commit b4351d9

Please sign in to comment.