forked from eclipse-aaspe/server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckFormat.ps1
33 lines (26 loc) · 978 Bytes
/
CheckFormat.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<#
.SYNOPSIS
This script checks the format of the code.
#>
$ErrorActionPreference = "Stop"
Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
AssertDotnet, `
AssertDotnetFormatVersion, `
GetArtefactsDir
function Main
{
AssertDotnetFormatVersion
Set-Location $PSScriptRoot
Write-Host "Inspecting the code format with dotnet-format..."
$artefactsDir = GetArtefactsDir
New-Item -ItemType Directory -Force -Path $artefactsDir|Out-Null
$reportPath = Join-Path $artefactsDir "dotnet-format-report.json"
dotnet format --verify-no-changes --report $reportPath --exclude "**/DocTest*.cs"
$formatReport = Get-Content $reportPath |ConvertFrom-Json
if ($formatReport.Count -ge 1)
{
throw "There are $( $formatReport.Count ) dotnet-format issue(s). " + `
"The report is stored in: $reportPath"
}
}
$previousLocation = Get-Location; try { Main } finally { Set-Location $previousLocation }