mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
42 lines
1.1 KiB
PowerShell
Executable File
42 lines
1.1 KiB
PowerShell
Executable File
param (
|
|
[Parameter(Mandatory)]
|
|
[string]$OutDir,
|
|
[Parameter(Mandatory)][string]$Tag,
|
|
[Parameter(Mandatory)][string]$PackageName
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$Url = "https://github.com/oven-sh/WebKit/releases/download/autobuild-$Tag/$PackageName.tar.gz"
|
|
$CacheDir = (mkdir -Force (Join-Path $PSScriptRoot "../.cache"))
|
|
$TarPath = Join-Path $CacheDir "$PackageName-$Tag.tar.gz"
|
|
|
|
if (Test-Path $OutDir\.tag) {
|
|
$CurrentTag = Get-Content -Path (Join-Path $OutDir ".tag")
|
|
if ($CurrentTag -eq $Tag) {
|
|
return
|
|
}
|
|
}
|
|
|
|
Remove-Item $OutDir -ErrorAction SilentlyContinue -Recurse
|
|
$null = mkdir -Force $OutDir
|
|
try {
|
|
Write-Host "-- Downloading WebKit"
|
|
if (!(Test-Path $TarPath)) {
|
|
try {
|
|
Invoke-WebRequest $Url -OutFile $TarPath
|
|
} catch {
|
|
Write-Error "Failed to fetch WebKit from: $Url"
|
|
throw $_
|
|
}
|
|
}
|
|
|
|
Push-Location $CacheDir
|
|
tar.exe "-xzf" "$PackageName-$Tag.tar.gz" -C (Resolve-Path -Relative $OutDir\..\).replace('\', '/')
|
|
Pop-Location
|
|
|
|
Set-Content -Path (Join-Path $OutDir ".tag") -Value "$Tag"
|
|
} catch {
|
|
Remove-Item -Force -ErrorAction SilentlyContinue $OutDir
|
|
throw $_
|
|
} |