Files
bun.sh/scripts/update-submodules.ps1
2024-09-10 19:57:19 -07:00

25 lines
888 B
PowerShell
Executable File

param(
[switch]$WebKit = $false
)
$ErrorActionPreference = 'Stop'
$ScriptDir = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
Push-Location (Join-Path $ScriptDir '..')
try {
$Names = Get-Content .gitmodules | Select-String 'path = (.*)' | ForEach-Object { $_.Matches.Groups[1].Value }
# we will exclude webkit unless you explicitly clone it yourself (a huge download)
if (!($WebKit) -and (-not (Test-Path "src/bun.js/WebKit/.git"))) {
$Names = $Names | Where-Object { $_ -ne 'src/bun.js/WebKit' }
}
if ($env:FORCE_UPDATE_SUBMODULES -eq "1") {
# Set --force in CI.
git submodule update --init --recursive --progress --depth 1 --checkout --force @NAMES
} else {
git submodule update --init --recursive --progress --depth 1 --checkout @NAMES
}
if ($LASTEXITCODE -ne 0) {
throw "git submodule update failed"
}
} finally { Pop-Location }