Script to setup Windows 10 1903
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

68 lines
1.5 KiB

# Check module
Write-Verbose -Message "Run Lint" -Verbose
$Results = @(Get-ChildItem -Path src -File -Recurse -Include *.ps1, *.psm1 | Invoke-ScriptAnalyzer)
if ($Results | Where-Object -FilterScript {($_.Severity -eq "Error") -or ($_.Severity -eq "ParseError")})
{
Write-Verbose -Message "Found script issue" -Verbose
$Results | Where-Object -FilterScript {($_.Severity -eq "Error") -or ($_.Severity -eq "ParseError")} | ForEach-Object -Process {
[PSCustomObject]@{
Line = $_.Line
Message = $_.Message
Path = $_.ScriptPath
}
} | Format-Table -AutoSize -Wrap
# Exit with a non-zero status to fail the job
exit 1
}
Write-Verbose -Message "Check JSONs validity" -Verbose
# Check JSONs
$JSONs = [Array]::TrueForAll((@(Get-ChildItem -Path Wrapper -File -Recurse -Filter *.json).FullName),
[Predicate[string]]{
param($JSON)
Test-Json -Path $JSON -ErrorAction Ignore
})
if (-not $JSONs)
{
Write-Verbose -Message "Found JSON issue" -Verbose
# Exit with a non-zero status to fail the job
exit 1
}
Write-Verbose -Message "Check psd1 files" -Verbose
# Check psd1 files
function Parse-PSD1
{
[CmdletBinding()]
param
(
[Microsoft.PowerShell.DesiredStateConfiguration.ArgumentToConfigurationDataTransformation()]
[hashtable]
$Path
)
return $Path
}
Get-ChildItem -Path src -File -Filter *.psd1 -Recurse | ForEach-Object -Process {
$File = $_.FullName
try
{
Parse-PSD1 -Path $_.FullName -ErrorAction Stop | Out-Null
}
catch
{
Write-Verbose -Message $File -Verbose
# Exit with a non-zero status to fail the job
exit 1
}
}