support bare executables and xbin on windows for jq
[webi-installers/.git] / _webi / webi.ps1
index ebe0a02ac93759bc9ce8aba9afb0e3fd34d4b392..7d8de291ee643c0a19da0cef62292933ec275c23 100644 (file)
@@ -18,6 +18,10 @@ if (!(Test-Path -Path .local\bin))
 {
     New-Item -Path .local\bin -ItemType Directory
 }
+if (!(Test-Path -Path .local\xbin))
+{
+    New-Item -Path .local\xbin -ItemType Directory
+}
 Set-Content -Path .local\bin\webi.bat -Value "@echo off`r`npushd %USERPROFILE%`r`npowershell -ExecutionPolicy Bypass .local\bin\webi.ps1 %1`r`npopd"
 if (!(Test-Path -Path .local\opt))
 {
@@ -52,9 +56,10 @@ if (!(Test-Path -Path .local\bin\pathman.exe))
 
 # Fetch <whatever>.ps1
 # TODO detect formats
-# Invoke-WebRequest -UserAgent "Windows amd64" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -OutFile ".\.local\tmp\$exename.install.ps1"
-echo "Downloading $Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar"
-& curl.exe -fsSL -A "$Env:WEBI_UA" "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,tar" -o .\.local\tmp\$exename.install.ps1
+$PKG_URL = "$Env:WEBI_HOST/api/installers/$exename.ps1?formats=zip,exe,tar"
+echo "Downloading $PKG_URL"
+# Invoke-WebRequest -UserAgent "Windows amd64" "$PKG_URL" -OutFile ".\.local\tmp\$exename.install.ps1"
+& curl.exe -fsSL -A "$Env:WEBI_UA" "$PKG_URL" -o .\.local\tmp\$exename.install.ps1
 
 # Run <whatever>.ps1
 powershell .\.local\tmp\$exename.install.ps1