-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
49 lines (42 loc) · 1.14 KB
/
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
[CmdletBinding()]
Param(
[array] $BuildSteps
)
$modules = @(
"Brasse.Powershell.Omnishell"
)
$settings = Get-Content -Path "$PSScriptRoot\settings.json" `
| ConvertFrom-Json
#Load Requirements
Write-Host "Loading Requirements..."
$settings.modules | ForEach-Object {
$isAvailable = Get-Module -ListAvailable -Name $_.Name `
| Where-Object -Property Version -Value $_.Version -EQ
if (!$isAvailable) {
Install-Module $_.Name -RequiredVersion $_.Version
}
Import-Module $_.Name -RequiredVersion $_.Version
}
#Run Test
$modules | ForEach-Object {
Get-ChildItem -Path "$PSScriptRoot\src\$_\Tests\*.ps1" | ForEach-Object {
Write-Host "Running Tests for $($_.Name) ..."
Invoke-Pester $_.FullName
}
}
#Run Anylyzer
$modules | ForEach-Object {
Write-Host "Anylyzing code for $_ ..."
Invoke-ScriptAnalyzer -Path "$PSScriptRoot\src\$_\" -Recurse
}
function Import{
$modules | ForEach-Object {
Remove-Module "$_" -Force
Import-Module "$PSScriptRoot\src\$_\$_.psm1"
Write-Host "Imported module $_"
}
}
#Run custom steps
foreach ($buildStep in $BuildSteps){
&$buildStep
}