spellcheck.ps1 814 B

123456789101112131415161718192021222324252627282930313233343536
  1. #!/usr/bin/env pwsh
  2. <#
  3. .SYNOPSIS
  4. Checks spelling of code and docs.
  5. #>
  6. # Get path.
  7. $scriptDir = Split-Path $PSCommandPath -Parent
  8. $projectDir = (Get-Item $scriptDir).Parent
  9. # Set working directory to root of project.
  10. Push-Location $projectDir
  11. $ExitCode = 0
  12. # Run spell checker.
  13. codespell `
  14. --skip="migrations,vendor,_build,*.css.map,*.jpg,*.png,*.pyc" `
  15. --ignore-words-list="assertIn" `
  16. coderedcms docs
  17. $ExitCode = $LastExitCode
  18. # Print output.
  19. if ($ExitCode -eq 0) {
  20. Write-Host "Spelling looks good!"
  21. }
  22. else {
  23. # Write the error in a way that shows up as the failure reason in Azure Pipelines.
  24. Write-Host -ForegroundColor Red `
  25. "##vso[task.LogIssue type=error;]Spelling errors! 👩‍🏫"
  26. }
  27. # Unset working directory and exit with pytest's code.
  28. Pop-Location
  29. exit $ExitCode