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