Public/Get-ModuleFunctions.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
function Get-ModuleFunctions {
    <#
    .SYNOPSIS
        List functions imported by a module

    .FUNCTIONALITY
        CI/CD

    .DESCRIPTION
        List functions imported by a module. Note that this actually imports the module.

    .PARAMETER Name
        Name or path to module to inspect. Defaults to ProjectPath\ProjectName

    .NOTES
        We assume you are in the project root, for several of the fallback options

    .EXAMPLE
        Get-ModuleFunctions

    .LINK
        https://github.com/RamblingCookieMonster/BuildHelpers

    .LINK
        about_BuildHelpers
    #>

    [cmdletbinding()]
    param(
        [parameter(ValueFromPipeline = $True)]
        [Alias('Path')]
        [string]$Name
    )
    Process
    {
        if(-not $Name)
        {
            $BuildDetails = Get-BuildVariables
            $Name = Join-Path ($BuildDetails.ProjectPath) (Get-ProjectName)
        }

        $params = @{
            Force = $True
            Passthru = $True
            Name = $Name
        }

        ( Import-Module @params ).ExportedCommands.Keys
    }
}