Skip to content

Commit

Permalink
Fix formatting of scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Freezor committed Jun 6, 2024
1 parent 51bc445 commit c4faadd
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/BuildForRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $ErrorActionPreference = "Stop"

Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
AssertDotnet, `
GetArtefactsDir
GetArtefactsDir

function CopyContentForDemo($Destination)
{
Expand Down
13 changes: 10 additions & 3 deletions src/Check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ function LogAndExecute($Expression)

function Main
{
LogAndExecute "$(Join-Path $PSScriptRoot "CheckFormat.ps1")"
LogAndExecute "$(Join-Path $PSScriptRoot "CheckHelpInReadme.ps1")"
LogAndExecute "$( Join-Path $PSScriptRoot "CheckFormat.ps1" )"
LogAndExecute "$( Join-Path $PSScriptRoot "CheckHelpInReadme.ps1" )"
}

$previousLocation = Get-Location; try { Main } finally { Set-Location $previousLocation }
$previousLocation = Get-Location; try
{
Main
}
finally
{
Set-Location $previousLocation
}
26 changes: 14 additions & 12 deletions src/Common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ function AssertDotnet
}
else
{
throw "dotnet could not be found in the PATH. Look if you could find it, e.g., in " + `
"$( Join-Path $env:LOCALAPPDATA "Microsoft\dotnet" ) and add it to PATH."
throw "dotnet could not be found in the PATH. Look if you could find it, e.g., in " + `
"$( Join-Path $env:LOCALAPPDATA "Microsoft\dotnet" ) and add it to PATH."
}
}
}

function FindDotnetToolVersion($PackageID) {
function FindDotnetToolVersion($PackageID)
{
AssertDotnet

$version = ''
Expand Down Expand Up @@ -55,23 +56,24 @@ function FindDotnetToolVersion($PackageID) {
.SYNOPSIS
Check the version of the given dotnet tool.
#>
function AssertDotnetToolVersion($PackageID, $ExpectedVersion) {
function AssertDotnetToolVersion($PackageID, $ExpectedVersion)
{
AssertDotnet

$version = FindDotnetToolVersion -PackageID $PackageID
if ($version -eq '')
{
throw "No $PackageID could be found. Have you installed it? " + `
"Check the list of the installed dotnet tools with: " + `
"`dotnet tool list` and `dotnet tool list -g`."
throw "No $PackageID could be found. Have you installed it? " + `
"Check the list of the installed dotnet tools with: " + `
"`dotnet tool list` and `dotnet tool list -g`."
}
else
{
if ($version -ne $ExpectedVersion)
{
throw "Expected $PackageID version $ExpectedVersion, but got: $version;" + `
"Check the list of the installed dotnet tools with: " + `
"`dotnet tool list` and `dotnet tool list -g`."
throw "Expected $PackageID version $ExpectedVersion, but got: $version;" + `
"Check the list of the installed dotnet tools with: " + `
"`dotnet tool list` and `dotnet tool list -g`."
}
# else: the version is correct.
}
Expand All @@ -95,5 +97,5 @@ function GetArtefactsDir

Export-ModuleMember -Function `
AssertDotnet, `
AssertDotnetFormatVersion, `
GetArtefactsDir
AssertDotnetFormatVersion, `
GetArtefactsDir
11 changes: 9 additions & 2 deletions src/FormatCode.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ $ErrorActionPreference = "Stop"

Import-Module (Join-Path $PSScriptRoot Common.psm1) -Function `
AssertDotnet, `
AssertDotnetFormatVersion
AssertDotnetFormatVersion

function Main
{
Expand All @@ -18,4 +18,11 @@ function Main
dotnet format --exclude "**/DocTest*.cs"
}

$previousLocation = Get-Location; try { Main } finally { Set-Location $previousLocation }
$previousLocation = Get-Location; try
{
Main
}
finally
{
Set-Location $previousLocation
}
2 changes: 1 addition & 1 deletion src/PackageRelease.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Main

$versionRe = [Regex]::new(
'^[0-9]{4}-(0[1-9]|10|11|12)-(0[1-9]|1[0-9]|2[0-9]|3[0-1])' +
'(\.(alpha|beta))?$')
'(\.(alpha|beta))?$')

$latestVersionRe = [Regex]::new('^LATEST(\.(alpha|beta))?$')

Expand Down

0 comments on commit c4faadd

Please sign in to comment.