summaryrefslogtreecommitdiff
path: root/xmake/scripts
diff options
context:
space:
mode:
authorruki <[email protected]>2024-09-14 00:56:23 +0800
committerruki <[email protected]>2024-09-14 00:56:23 +0800
commit1be14dcae978f2969e708bb9224e36a8a7b6f77f (patch)
treecd6745d50d4877909cfd592463f9ace0105ab4af /xmake/scripts
parent8cfa4e691396c5c9ded6ed5ab45b8a45a73bd01f (diff)
download file using powershell
Diffstat (limited to 'xmake/scripts')
-rwxr-xr-xxmake/scripts/download.ps127
1 files changed, 27 insertions, 0 deletions
diff --git a/xmake/scripts/download.ps1 b/xmake/scripts/download.ps1
new file mode 100755
index 000000000..c19983699
--- /dev/null
+++ b/xmake/scripts/download.ps1
@@ -0,0 +1,27 @@
+#!/usr/bin/env pwsh
+#Requires -version 5
+
+param (
+ [string]$url,
+ [string]$outputfile
+)
+
+& {
+ function writeErrorTip($msg) {
+ Write-Host $msg -BackgroundColor Red -ForegroundColor White
+ }
+
+ $temppath = ([System.IO.Path]::GetTempPath(), $env:TMP, $env:TEMP, "$(Get-Location)" -ne $null)[0]
+ [Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
+
+ function download {
+ try {
+ Invoke-Webrequest $url -OutFile $outputfile -UseBasicParsing
+ } catch {
+ writeErrorTip 'Download failed!'
+ throw
+ }
+ }
+
+ download
+}