Reject native verification parse errors before launch and fix split dispatch branch
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
param([Parameter(Mandatory)][string]$EvidenceDir,[string[]]$Sources)
|
||||
$ErrorActionPreference='Stop'
|
||||
New-Item -ItemType Directory -Path $EvidenceDir -Force|Out-Null
|
||||
if(!$Sources){$Sources=@(Get-ChildItem $PSScriptRoot -Filter '*.ps1'|Select-Object -ExpandProperty FullName)}
|
||||
$results=@(foreach($source in $Sources){
|
||||
$errors=$null
|
||||
[Management.Automation.Language.Parser]::ParseFile($source,[ref]$null,[ref]$errors)|Out-Null
|
||||
@{source=$source;passed=($errors.Count-eq0);errors=@($errors|Select-Object ErrorId,Message,@{n='line';e={$_.Extent.StartLineNumber}})}
|
||||
})
|
||||
$passed=$results.Count-gt0-and@($results|Where-Object passed -ne $true).Count-eq0
|
||||
@{passed=$passed;checks=$results}|ConvertTo-Json -Depth 8|Set-Content (Join-Path $EvidenceDir 'syntax-result.json')
|
||||
if(!$passed){exit 1};exit 0
|
||||
Reference in New Issue
Block a user