Skip to content

Instantly share code, notes, and snippets.

@asears
Last active February 7, 2022 14:51
Show Gist options
  • Select an option

  • Save asears/04f4a488c4987456c57bffa478eeaa55 to your computer and use it in GitHub Desktop.

Select an option

Save asears/04f4a488c4987456c57bffa478eeaa55 to your computer and use it in GitHub Desktop.
Test Bicep Files
# Get-ChildItem -Recurse -Filter "*.bicep" | foreach { Test-BicepFile -Path $_.fullname }
# https://github.com/Azure/bicep/issues/5828
$biceps = Get-ChildItem -Path . -Include "*.bicep" -r
$errors = 0
$numberOfFiles = $biceps.Length
foreach ($file in $biceps) {
$fileName = $file.Name
Write-Host "`n-------- Processing $fileName..."
bicep build $file.FullName
if ($LASTEXITCODE -ne 0) {
Write-Warning "Compiling $fileName failed"
$errors += 1
}
}
Write-Host "`n-------- Summary"
Write-Host "Number of files:`t $numberOfFiles"
Write-Host "Successful builds:`t $($numberOfFiles - $errors)"
Write-Host "Failed builds:`t`t $errors"
if ($errors -gt 0){
exit 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment