diff options
| author | ruki <[email protected]> | 2024-09-14 06:51:23 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-09-14 06:51:23 +0800 |
| commit | 8dab4c87e8cd9e2a2ae106c7a0236294246478b2 (patch) | |
| tree | 43828dae7056131a4b717aefece411b9bd310f53 /xmake/scripts | |
| parent | 8cfa4e691396c5c9ded6ed5ab45b8a45a73bd01f (diff) | |
| parent | 5994ea556a485b2a6ddecaafb60d5528def6dddb (diff) | |
Merge pull request #5616 from xmake-io/ps
download file using powershell
Diffstat (limited to 'xmake/scripts')
| -rwxr-xr-x | xmake/scripts/download.ps1 | 27 | ||||
| -rwxr-xr-x | xmake/scripts/unzip.ps1 | 24 |
2 files changed, 51 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 +} diff --git a/xmake/scripts/unzip.ps1 b/xmake/scripts/unzip.ps1 new file mode 100755 index 000000000..46947bfd3 --- /dev/null +++ b/xmake/scripts/unzip.ps1 @@ -0,0 +1,24 @@ +#!/usr/bin/env pwsh +#Requires -version 5 + +param ( + [string]$archivefile, + [string]$outputdir +) + +& { + function writeErrorTip($msg) { + Write-Host $msg -BackgroundColor Red -ForegroundColor White + } + + function unzip { + try { + Expand-Archive -Path $archivefile -DestinationPath $outputdir + } catch { + writeErrorTip 'Unzip failed!' + throw + } + } + + unzip +} |
