Skip to content

Commit 8a07d0f

Browse files
committed
WIP: ref!(webi): cleanup for later
1 parent e452de7 commit 8a07d0f

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

webi/webi-pwsh.ps1

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ Set-ExecutionPolicy -Scope Process Bypass
44
$ErrorActionPreference = 'Stop'
55
$ProgressPreference = 'SilentlyContinue'
66

7-
$my_version = 'v1.1.16'
7+
$my_version = 'v1.2.0'
88

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

@@ -64,20 +64,25 @@ function Get-UserAgent {
6464
"Windows/10+ $my_arch msvc"
6565
}
6666

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

71-
# See note on Set-ExecutionPolicy above
72-
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"
73-
# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
74-
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore
75-
if (!(Test-Path -Path "$HOME\.local\opt")) {
76-
New-Item -Path "$HOME\.local\opt" -ItemType Directory -Force | Out-Null
77-
}
78-
# TODO windows version of mktemp -d
79-
if (!(Test-Path -Path "$HOME\.local\tmp")) {
80-
New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
73+
# See note on Set-ExecutionPolicy above
74+
Set-Content -Path "$HOME\.local\bin\webi.bat" -Value "@echo off`r`npowershell -ExecutionPolicy Bypass %USERPROFILE%\.local\bin\webi-pwsh.ps1 %*"
75+
76+
# Backwards-compat bugfix: remove old webi-pwsh.ps1 location
77+
Remove-Item -Path "$HOME\.local\bin\webi.ps1" -Recurse -ErrorAction Ignore
78+
79+
# TODO windows version of mktemp -d
80+
IF (Test-Path -Path "$HOME\.local\tmp") {
81+
Write-Host " Found $HOME\.local\tmp\"
82+
} ELSE {
83+
Write-Host " Creating $HOME\.local\tmp\"
84+
$null = New-Item -Path "$HOME\.local\tmp" -ItemType Directory -Force | Out-Null
85+
}
8186
}
8287

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

127132
# Run <whatever>.ps1
128-
& "$HOME\.local\tmp\${exename}.install.ps1"
133+
& $HOME\.local\tmp\${exename}.install.ps1

0 commit comments

Comments
 (0)