@@ -13,8 +13,7 @@ Properties {
1313 $lines = ' ----------------------------------------------------------------------'
1414
1515 $Verbose = @ {}
16- if ($ENV: BHCommitMessage -match " !verbose" )
17- {
16+ if ($ENV: BHCommitMessage -match " !verbose" ) {
1817 $Verbose = @ {Verbose = $True }
1918 }
2019}
@@ -30,23 +29,20 @@ Task Init {
3029 " `n "
3130}
3231
33-
3432Task Analyze - Depends Init {
3533 $saResults = Invoke-ScriptAnalyzer - Path $ENV: BHModulePath - Severity @ (' Error' , ' Warning' ) - Recurse - Verbose:$false
3634 if ($saResults ) {
37- $saResults | Format-Table
38- # Write-Error -Message 'One or more Script Analyzer errors/warnings where found. Build cannot continue!'
35+ $saResults | Format-Table
36+ # Write-Error -Message 'One or more Script Analyzer errors/warnings where found. Build cannot continue!'
3937 }
4038}
4139
42-
4340Task UnitTests - Depends Init {
4441 $lines
4542 ' Running quick unit tests to fail early if there is an error'
46- $TestResults = Invoke-Pester - Path $ProjectRoot \Tests\* unit* - PassThru - Tag Build
47-
48- if ($TestResults.FailedCount -gt 0 )
49- {
43+ $TestResults = Invoke-Pester - Path $ProjectRoot \Tests\* unit* - PassThru - Tag Build
44+
45+ if ($TestResults.FailedCount -gt 0 ) {
5046 Write-Error " Failed '$ ( $TestResults.FailedCount ) ' tests, build failed"
5147 }
5248 " `n "
@@ -63,13 +59,12 @@ Task Test -Depends UnitTests {
6359 $CodeCoverage.AddRange ($CodeFiles.FullName )
6460 $Script :TestResults = Invoke-Pester - Path $ProjectRoot \Tests - CodeCoverage $CodeCoverage - PassThru - OutputFormat NUnitXml - OutputFile $TestFilePath
6561
66- # In Appveyor? Upload our tests! #Abstract this into a function?
67- If ($ENV: BHBuildSystem -eq ' AppVeyor' )
68- {
69- [xml ]$content = Get-Content $TestFilePath
70- $content .' test-results' .' test-suite' .type = " Powershell"
71- $content.Save ($TestFilePath )
62+ [xml ]$content = Get-Content $TestFilePath
63+ $content .' test-results' .' test-suite' .type = " Powershell"
64+ $content.Save ($TestFilePath )
7265
66+ # In Appveyor? Upload our tests! #Abstract this into a function?
67+ If ($ENV: BHBuildSystem -eq ' AppVeyor' ) {
7368 " Uploading $ProjectRoot \$TestFile to AppVeyor"
7469 " JobID: $env: APPVEYOR_JOB_ID "
7570 (New-Object ' System.Net.WebClient' ).UploadFile(" https://ci.appveyor.com/api/testresults/nunit/$ ( $env: APPVEYOR_JOB_ID ) " , (Resolve-Path $TestFilePath ))
@@ -79,8 +74,7 @@ Task Test -Depends UnitTests {
7974
8075 # Failed tests?
8176 # Need to tell psake or it will proceed to the deployment. Danger!
82- if ($TestResults.FailedCount -gt 0 )
83- {
77+ if ($TestResults.FailedCount -gt 0 ) {
8478 Write-Error " Failed '$ ( $TestResults.FailedCount ) ' tests, build failed"
8579 }
8680 " `n "
@@ -89,9 +83,9 @@ Task Test -Depends UnitTests {
8983Task Build - Depends Test {
9084 $lines
9185
92- $functions = Get-ChildItem " $ENV: BHModulePath \Public\*.ps1" |
93- Where-Object { $_.name -notmatch ' Tests' } |
94- Select-Object - ExpandProperty basename
86+ $functions = Get-ChildItem " $ENV: BHModulePath \Public\*.ps1" |
87+ Where-Object { $_.name -notmatch ' Tests' } |
88+ Select-Object - ExpandProperty basename
9589
9690 # Load the module, read the exported functions, update the psd1 FunctionsToExport
9791 Set-ModuleFunctions - Name $env: BHPSModuleManifest - FunctionsToExport $functions
@@ -105,11 +99,11 @@ Task Build -Depends Test {
10599 }
106100 $Script :version = [version ]::New($version.Major , $version.Minor , $version.Build )
107101 Write-Host " Using version: $version "
108-
102+
109103 Update-Metadata - Path $env: BHPSModuleManifest - PropertyName ModuleVersion - Value $version
110104
111105 # Update Code Coverage
112- Function Update-CodeCoveragePercent {
106+ Function Update-CodeCoveragePercent {
113107 param (
114108 [int ]$CodeCoverage = 0 ,
115109 [string ]$TextFilePath = " $Env: BHProjectPath \Readme.md"
@@ -138,16 +132,15 @@ Task Build -Depends Test {
138132Task MakePackage - Depends Build, Test {
139133 $lines
140134
141- function ZipFiles
142- {
135+ function ZipFiles {
143136 param ( $zipfilename , $sourcedir )
144- Add-Type - Assembly System.IO.Compression.FileSystem
137+ Add-Type - Assembly System.IO.Compression.FileSystem
145138 $compressionLevel = [System.IO.Compression.CompressionLevel ]::Optimal
146139 [System.IO.Compression.ZipFile ]::CreateFromDirectory($sourcedir ,
147- $zipfilename , $compressionLevel , $true )
140+ $zipfilename , $compressionLevel , $true )
148141 }
149142
150- function New-MakePackage {
143+ function New-MakePackage {
151144 param (
152145 [string ]$PackageName ,
153146 [string ]$PackagePath ,
@@ -171,24 +164,21 @@ Task Deploy -Depends Build,MakePackage {
171164 $lines
172165
173166 # Gate deployment
174- if (
167+ if (
175168 $ENV: BHBuildSystem -ne ' Unknown' -and
176169 $ENV: BHBranchName -eq " master" -and
177170 $ENV: BHCommitMessage -match ' !deploy'
178- )
179- {
171+ ) {
180172 $Params = @ {
181173 Path = $ProjectRoot
182174 Force = $true
183175 }
184176
185177 Invoke-PSDeploy @Verbose @Params
186- }
187- else
188- {
178+ } else {
189179 " Skipping deployment: To deploy, ensure that...`n " +
190180 " `t * You are in a known build system (Current: $ENV: BHBuildSystem )`n " +
191181 " `t * You are committing to the master branch (Current: $ENV: BHBranchName ) `n " +
192182 " `t * Your commit message includes !deploy (Current: $ENV: BHCommitMessage )"
193183 }
194- }
184+ }
0 commit comments