-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHelper.Build.ps1
65 lines (55 loc) · 1.71 KB
/
Helper.Build.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
Task InstallDependencies {
$Name = @(
'Pester'
'PSScriptAnalyzer'
'PSDeploy'
)
foreach($dep in $Name){
if(-not (Get-module -ListAvailable $dep)){
Install-Module $dep -Force
}
}
}
Task Analyze {
$params = @{
Path = "$BuildRoot\"
Severity = @('Error', 'Warning')
Recurse = $true
Verbose = $false
ExcludeRule = 'PSUseDeclaredVarsMoreThanAssignments', 'PSAvoidUsingCmdletAliases'
}
$results = Invoke-ScriptAnalyzer @params
if ($results) {
$results | Format-Table
throw "One or more PSScriptAnalyzer errors/warnings where found."
}
}
task Test {
$invokePesterParams = @{
Strict = $true
PassThru = $true
Verbose = $false
EnableExit = $false
}
# Publish Test Results as NUnitXml
$testResults = Invoke-Pester @invokePesterParams;
$numberFails = $testResults.FailedCount
assert($numberFails -eq 0) ('Failed "{0}" unit tests.' -f $numberFails)
}
Task Clean {
$buildfolder = ".\dist"
if(test-path $buildfolder){
Remove-Item -Recurse -Force $buildfolder
}
}
Task Build {
$ModuleName = "Helper"
$path = new-item -ItemType Directory '.\dist' -Force
$artifact = join-path $path "$ModuleName.zip"
Compress-Archive -Path .\*.psm1 -DestinationPath $artifact
Compress-Archive -Update -Path ".\*.psd1" -DestinationPath $artifact
Compress-Archive -Update -Path ".\LICENSE" -DestinationPath $artifact
Compress-Archive -Update -Path ".\README.md" -DestinationPath $artifact
Compress-Archive -Update -Path ".\en-US" -DestinationPath $artifact
}
Task . InstallDependencies, Analyze, Test, Clean, Build