121eea057418bb571dc29baa67346b2c7d890599
[webi-installers/.git] / _webi / template.ps1
1 #!/usr/bin/env pwsh
2
3 # this allows us to call ps1 files, which allows us to have spaces in filenames
4 # ('powershell "$Env:USERPROFILE\test.ps1" foo' will fail if it has a space in
5 # the path but '& "$Env:USERPROFILE\test.ps1" foo' will work even with a space)
6 Set-ExecutionPolicy -Scope Process Bypass
7
8 # If a command returns an error, halt the script.
9 $ErrorActionPreference = 'Stop'
10
11 # Ignore progress events from cmdlets so Invoke-WebRequest is not painfully slow
12 $ProgressPreference = 'SilentlyContinue'
13
14 $Env:WEBI_HOST = 'https://webinstall.dev'
15 #$Env:WEBI_PKG = 'node@lts'
16 #$Env:PKG_NAME = node
17 #$Env:WEBI_VERSION = v12.16.2
18 #$Env:WEBI_PKG_URL = "https://.../node-....zip"
19 #$Env:WEBI_PKG_FILE = "node-v12.16.2-win-x64.zip"
20
21 # Switch to userprofile
22 pushd $Env:USERPROFILE
23
24 # Make paths if needed
25 if (!(Test-Path -Path Downloads))
26 {
27     New-Item -Path Downloads -ItemType Directory -Force
28 }
29 if (!(Test-Path -Path .local\bin))
30 {
31     New-Item -Path .local\bin -ItemType Directory -Force
32 }
33 if (!(Test-Path -Path .local\opt))
34 {
35     New-Item -Path .local\opt -ItemType Directory -Force
36 }
37
38 # {{ baseurl }}
39 # {{ version }}
40
41 function webi_add_path
42 {
43     & "$Env:USERPROFILE\.local\bin\pathman.exe" add "$args[0]"
44     # Note: not all of these work as expected, so we use the unix-style, which is most consistent
45     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
46     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
47     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
48 }
49
50 # Run pathman to set up the folder
51 & "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
52
53 {{ installer }}
54
55 # Done
56 popd