71d4f8249b7a853cdec8d6b9c40b1975f1e11b20
[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
25 New-Item -Path Downloads -ItemType Directory -Force | out-null
26 New-Item -Path .local\bin -ItemType Directory -Force | out-null
27 New-Item -Path .local\opt -ItemType Directory -Force | out-null
28
29 # {{ baseurl }}
30 # {{ version }}
31
32 function webi_add_path
33 {
34     & "$Env:USERPROFILE\.local\bin\pathman.exe" add "$args[0]"
35     # Note: not all of these work as expected, so we use the unix-style, which is most consistent
36     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
37     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add "$Env:USERPROFILE\.local\bin"
38     #& "$Env:USERPROFILE\.local\bin\pathman.exe" add %USERPROFILE%\.local\bin
39 }
40
41 # Run pathman to set up the folder
42 & "$Env:USERPROFILE\.local\bin\pathman.exe" add ~/.local/bin
43
44 {{ installer }}
45
46 # Done
47 popd