Skip to content

Commit

Permalink
Added Basic build script
Browse files Browse the repository at this point in the history
  • Loading branch information
comnam90 committed Sep 22, 2020
1 parent c7ee463 commit df34bfc
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions build/build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[cmdletbinding()]
param(
[switch]$Bootstrap,
[switch]$Test,
[switch]$CodeCoverage
)

# Variables
$build = @{
PesterVersion = [version]'4.10.1'
}

# Bootstrap step
if ($Bootstrap) {
Write-Information "Validate and install required build pre-reqs"
if ( $Build['PesterVersion'] -inotin (Get-Module Pester -ListAvailable).Version ) {
Write-Warning 'Required "Pester" module is missing. Installing required "Pester" module...'
Install-Module Pester -RequiredVersion $Build['PesterVersion'] -Force -Scope CurrentUser -SkipPublisherCheck
}
Import-Module Pester -RequiredVersion $Build['PesterVersion']
}

# Test step
if ($Test) {
if ( [version]$Build['PesterVersion'] -inotin (Get-Module Pester -ListAvailable).Version ) {
throw "Cannot find the required module 'Pester' version $($Build.PesterVersion)"
}

$ModuleFiles = Get-ChildItem -Path .\src -Recurse -Include "*.psm1", "*.ps1" | Select-Object -ExpandProperty FullName
$results = Invoke-Pester -Script .\Tests -CodeCoverage $ModuleFiles -PassThru

if ($CodeCoverage) {
"Coverage: {0:N2} %" -f (($results.CodeCoverage.NumberOfCommandsExecuted / $results.CodeCoverage.NumberOfCommandsAnalyzed) * 100)
}
}

0 comments on commit df34bfc

Please sign in to comment.