win: bugfix Env:WEBI_HOST in webi.ps1
[webi-installers/.git] / _webi / bootstrap.ps1
1 # If a command returns an error, halt the script.
2 $ErrorActionPreference = 'Stop'
3
4 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
5 $ProgressPreference = 'SilentlyContinue'
6
7 # Switch to userprofile
8 pushd $Env:USERPROFILE
9
10 # Make paths if needed
11 if (!(Test-Path -Path .local\bin))
12 {
13     New-Item -Path .local\bin -ItemType Directory
14 }
15
16 # {{ baseurl }}
17 # {{ version }}
18
19 # Enter path
20 pushd .local\bin
21
22 # TODO SetStrictMode
23 # TODO Test-Path variable:global:Env:WEBI_HOST ???
24 IF(!$Env:WEBI_HOST)
25 {
26     $Env:WEBI_HOST = "https://webinstall.dev"
27 }
28
29 # Fetch webi.bat
30 Invoke-WebRequest "$Env:WEBI_HOST/packages/_webi/webi.ps1.bat" -OutFile webi.bat
31 Invoke-WebRequest "$Env:WEBI_HOST/packages/_webi/webi.ps1" -OutFile webi.ps1
32
33 popd
34
35 # Run webi.bat
36 & .\.local\bin\webi.bat {{ exename }}
37
38 # Run pathman to set up the folder
39 & "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\.bin"
40
41 # Done
42 popd