Skip to content

Commit

Permalink
WIP: ref!(webi): cleanup for later
Browse files Browse the repository at this point in the history
  • Loading branch information
coolaj86 committed Nov 11, 2023
1 parent e452de7 commit 8a07d0f
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions webi/webi-pwsh.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Set-ExecutionPolicy -Scope Process Bypass
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'

$my_version = 'v1.1.16'
$my_version = 'v1.2.0'

IF ($null -eq $Env:WEBI_HOST -or $Env:WEBI_HOST -eq "") {
IF ($Env:WEBI_HOST.Length -eq 0) {
$Env:WEBI_HOST = "https://webinstall.dev"
}

Expand Down Expand Up @@ -64,20 +64,25 @@ function Get-UserAgent {
"Windows/10+ $my_arch msvc"
}

# Make paths if needed
# TODO replace all bin with opt\bin\
New-Item -Path "$HOME\.local\bin\" -ItemType Directory -Force | Out-Null
function Install-Webi {
# Make paths if needed
# TODO replace all bin with opt\bin\
$null = New-Item -Path "$HOME\.local\bin\" -ItemType Directory -Force
$null = New-Item -Path "$HOME\.local\opt\" -ItemType Directory -Force

# See note on Set-ExecutionPolicy above
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"
# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore
if (!(Test-Path -Path "$HOME\.local\opt")) {
New-Item -Path "$HOME\.local\opt" -ItemType Directory -Force | Out-Null
}
# TODO windows version of mktemp -d
if (!(Test-Path -Path "$HOME\.local\tmp")) {
New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
# See note on Set-ExecutionPolicy above
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"

# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore

# TODO windows version of mktemp -d
IF (Test-Path -Path "$HOME\.local\tmp") {
Write-Host " Found $HOME\.local\tmp\"
} ELSE {
Write-Host " Creating $HOME\.local\tmp\"
$null = New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
}
}

## show help if no params given or help flags are used
Expand Down Expand Up @@ -125,4 +130,4 @@ $PKG_URL = "$Env:WEBI_HOST/api/installers/$exename.ps1?$Formats&$Libc"
Invoke-DownloadUrl -URL $PKG_URL -Path $HOME\.local\tmp\$exename.install.ps1

# Run <whatever>.ps1
& "$HOME\.local\tmp\${exename}.install.ps1"
& $HOME\.local\tmp\${exename}.install.ps1

0 comments on commit 8a07d0f

Please sign in to comment.