chore: import upstream snapshot with attribution
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled
FreeBSD Smoke / FreeBSD Smoke (x86_64) (push) Has been cancelled
CI / Quality Guardrails (push) Has been cancelled
CI / Build & Test (macos-latest) (push) Has been cancelled
CI / Build & Test (ubuntu-latest) (push) Has been cancelled
CI / Build & Test (windows-latest) (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / PowerShell Syntax (push) Has been cancelled
CI / Windows Cross-Target Check (Linux) (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
param(
|
||||
[string[]]$Paths = @("scripts")
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
Set-StrictMode -Version Latest
|
||||
|
||||
$scriptFiles = @()
|
||||
foreach ($path in $Paths) {
|
||||
if (-not (Test-Path -LiteralPath $path)) {
|
||||
continue
|
||||
}
|
||||
|
||||
$scriptFiles += Get-ChildItem -LiteralPath $path -Recurse -File -Filter '*.ps1'
|
||||
}
|
||||
|
||||
if (-not $scriptFiles -or $scriptFiles.Count -eq 0) {
|
||||
Write-Host 'No PowerShell scripts found.' -ForegroundColor Yellow
|
||||
exit 0
|
||||
}
|
||||
|
||||
$hadErrors = $false
|
||||
|
||||
foreach ($file in $scriptFiles | Sort-Object FullName -Unique) {
|
||||
$tokens = $null
|
||||
$errors = $null
|
||||
[System.Management.Automation.Language.Parser]::ParseFile($file.FullName, [ref]$tokens, [ref]$errors) | Out-Null
|
||||
|
||||
if ($errors -and $errors.Count -gt 0) {
|
||||
$hadErrors = $true
|
||||
Write-Host "Parse errors in $($file.FullName):" -ForegroundColor Red
|
||||
foreach ($error in $errors) {
|
||||
$line = $error.Extent.StartLineNumber
|
||||
$column = $error.Extent.StartColumnNumber
|
||||
Write-Host " Line ${line}, Col ${column}: $($error.Message)" -ForegroundColor Red
|
||||
}
|
||||
} else {
|
||||
Write-Host "OK: $($file.FullName)" -ForegroundColor Green
|
||||
}
|
||||
}
|
||||
|
||||
if ($hadErrors) {
|
||||
exit 1
|
||||
}
|
||||
Reference in New Issue
Block a user