-
Notifications
You must be signed in to change notification settings - Fork 0
/
testpowershellmodule.ps1
42 lines (37 loc) · 1.32 KB
/
testpowershellmodule.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
param (
[string]$ModuleName,
[string]$Source = "",
[string]$Output = "",
[string]$Debug = 'false'
)
try
{
Write-Host "::group::Starting the Test PowerShell Module task..."
Write-Host "::group::Setting up variables"
$Debug = [System.Convert]::ToBoolean($Debug)
$sourcePath = if ([string]::IsNullOrEmpty($Source)) { $env:GITHUB_WORKSPACE } else { Join-Path $env:GITHUB_WORKSPACE $Source }
$outputPath = if ([string]::IsNullOrEmpty($Output)) { Join-Path $env:GITHUB_WORKSPACE "output" } else { Join-Path $env:GITHUB_WORKSPACE $Output }
$Module = Get-ChildItem -Path $sourcePath -Filter "$ModuleName.psd1" -Recurse
$ModuleRoot = $Module.Directory.FullName
$Destination = Join-Path $outputPath $ModuleName
$modulePath = Join-Path $Destination "$ModuleName.psm1"
$ManifestPath = Join-Path $Destination "$ModuleName.psd1"
if ($Debug)
{
Write-Host "ModuleName : $ModuleName"
Write-Host "SourcePath : $sourcePath"
Write-Host "OutputPath : $outputPath"
Write-Host "ModuleRoot : $ModuleRoot"
Write-Host "modulePath : $modulePath"
Write-Host "ManifestPath : $ManifestPath"
Write-Host "Destination : $Destination"
}
Test-ModuleManifest -Path $ManifestPath -Verbose
Import-Module $Destination -Verbose
Get-Module -Name $ModuleName
}
catch
{
Write-Host "##[error]An error occurred: $($_.Exception.Message)"
exit 1
}