diff --git a/src/Helper/Resolve-Dependency.ps1 b/src/Helper/Resolve-Dependency.ps1 index c3bb794..9d76571 100644 --- a/src/Helper/Resolve-Dependency.ps1 +++ b/src/Helper/Resolve-Dependency.ps1 @@ -1,4 +1,52 @@ function Resolve-Dependency { + <# + .SYNOPSIS + Tests defined optional dependencies and returns the result as bool. + + .DESCRIPTION + Use this function to test for optional modules. You can use it if you provide functions which needs special + modules but you don't want to make them required. + + Place a file called Dependency.json in your module root dir. The default format is: + + { + "Version": 0.1, + "Mandatory": {}, + "Optional": [ + { + "Name": "VMware", + "Modules": [ + "VMware.VimAutomation.Core" + ] + }, + { + "Name": "CiscoUCS", + "Modules": [] + } + ] + } + + .PARAMETER Name + Select the dependency item name you defined in the dependency.json. + .INPUTS + [None] + + .OUTPUTS + [bool] + + .EXAMPLE + If (-not (Resolve-Dependency -Name 'VMware')) { + Write-Error -Message ("Could not resolve the optional dependencies defined for {0}" -f 'VMware') -ErrorAction 'Stop' + } + + .NOTES + File Name : ResolveDependency.ps1 + Author : Marco Blessing - marco.blessing@googlemail.com + Requires : + + .LINK + https://github.com/OCram85/PSCredentialStore + #> [OutputType([bool])] [CmdletBinding()] param ( diff --git a/src/Helper/Test-Module.ps1 b/src/Helper/Test-Module.ps1 index 174dd32..7f18f95 100644 --- a/src/Helper/Test-Module.ps1 +++ b/src/Helper/Test-Module.ps1 @@ -1,11 +1,10 @@ function Test-Module { <# .SYNOPSIS - Internal helper to check optional dependencies. + Tests if the given module exists on the local system. .DESCRIPTION - Test-Dependency checks if the given module or pssnapin is available on the system. It returns a bool value - So it is possible to use this function in a if condition. + Tests if the given module is installed on the local system. It returns a bool value as result. .PARAMETER Name Define a item name you need to test