mirror of
https://github.com/bybrooklyn/alchemist.git
synced 2026-04-18 09:53:33 -04:00
Prepare 0.3.0-rc.2 with Windows support and regression tests
This commit is contained in:
62
scripts/windows_common.ps1
Normal file
62
scripts/windows_common.ps1
Normal file
@@ -0,0 +1,62 @@
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
$script:RepoRoot = Split-Path -Parent $PSScriptRoot
|
||||
|
||||
function Require-Tool {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hint
|
||||
)
|
||||
|
||||
if (Get-Command $Name -ErrorAction SilentlyContinue) {
|
||||
return
|
||||
}
|
||||
|
||||
throw "Required tool '$Name' was not found on PATH. $Hint"
|
||||
}
|
||||
|
||||
function Warn-If-Missing {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Name,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string]$Hint
|
||||
)
|
||||
|
||||
if (Get-Command $Name -ErrorAction SilentlyContinue) {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Warning "Optional tool '$Name' was not found on PATH. $Hint"
|
||||
}
|
||||
|
||||
function Invoke-Native {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[string[]]$Command,
|
||||
[string]$WorkingDirectory = $script:RepoRoot,
|
||||
[string]$Label = ""
|
||||
)
|
||||
|
||||
if ($Label) {
|
||||
Write-Host "── $Label ──"
|
||||
}
|
||||
|
||||
Push-Location $WorkingDirectory
|
||||
try {
|
||||
if ($Command.Count -gt 1) {
|
||||
& $Command[0] @($Command[1..($Command.Count - 1)])
|
||||
} else {
|
||||
& $Command[0]
|
||||
}
|
||||
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Command failed ($LASTEXITCODE): $($Command -join ' ')"
|
||||
}
|
||||
} finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user