-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 [Feature]: Add
passed
output and continue if fails (#39)
## Description - Add output `passed`, containing if the tests passed. - Add `Resolve-PSModuleDependency` to install and import all requirements before testing the module. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ]⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas
- Loading branch information
1 parent
4c10a36
commit 886f51f
Showing
5 changed files
with
103 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#Documentation: https://github.com/PowerShell/PSScriptAnalyzer/blob/master/docs/Cmdlets/Invoke-ScriptAnalyzer.md#-settings | ||
@{ | ||
#CustomRulePath='path\to\CustomRuleModule.psm1' | ||
#RecurseCustomRulePath='path\of\customrules' | ||
#Severity = @( | ||
# 'Error' | ||
# 'Warning' | ||
#) | ||
#IncludeDefaultRules=${true} | ||
ExcludeRules = @( | ||
'PSAvoidUsingWriteHost' | ||
) | ||
#IncludeRules = @( | ||
# 'PSAvoidUsingWriteHost', | ||
# 'MyCustomRuleName' | ||
#) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
function Resolve-PSModuleDependency { | ||
<# | ||
.SYNOPSIS | ||
Resolve dependencies for a module based on the manifest file. | ||
.DESCRIPTION | ||
Resolve dependencies for a module based on the manifest file, following PSModuleInfo structure | ||
.EXAMPLE | ||
Resolve-PSModuleDependency -Path 'C:\MyModule\MyModule.psd1' | ||
Installs all modules defined in the manifest file, following PSModuleInfo structure. | ||
.NOTES | ||
Should later be adapted to support both pre-reqs, and dependencies. | ||
Should later be adapted to take 4 parameters sets: specific version ("requiredVersion" | "GUID"), latest version ModuleVersion, | ||
and latest version within a range MinimumVersion - MaximumVersion. | ||
#> | ||
[Alias('Resolve-PSModuleDependencies')] | ||
[CmdletBinding()] | ||
param( | ||
# The path to the manifest file. | ||
[Parameter(Mandatory)] | ||
[string] $ManifestFilePath | ||
) | ||
|
||
Write-Verbose 'Resolving dependencies' | ||
|
||
$manifest = Import-PowerShellDataFile -Path $ManifestFilePath | ||
Write-Verbose "Reading [$ManifestFilePath]" | ||
Write-Verbose "Found [$($manifest.RequiredModules.Count)] modules to install" | ||
|
||
foreach ($requiredModule in $manifest.RequiredModules) { | ||
$installParams = @{} | ||
|
||
if ($requiredModule -is [string]) { | ||
$installParams.Name = $requiredModule | ||
} else { | ||
$installParams.Name = $requiredModule.ModuleName | ||
$installParams.MinimumVersion = $requiredModule.ModuleVersion | ||
$installParams.RequiredVersion = $requiredModule.RequiredVersion | ||
$installParams.MaximumVersion = $requiredModule.MaximumVersion | ||
} | ||
$installParams.Force = $true | ||
$installParams.Verbose = $false | ||
|
||
Write-Verbose "[$($installParams.Name)] - Installing module" | ||
$VerbosePreferenceOriginal = $VerbosePreference | ||
$VerbosePreference = 'SilentlyContinue' | ||
Install-Module @installParams -AllowPrerelease:$false | ||
$VerbosePreference = $VerbosePreferenceOriginal | ||
Write-Verbose "[$($installParams.Name)] - Importing module" | ||
$VerbosePreferenceOriginal = $VerbosePreference | ||
$VerbosePreference = 'SilentlyContinue' | ||
Import-Module @installParams | ||
$VerbosePreference = $VerbosePreferenceOriginal | ||
Write-Verbose "[$($installParams.Name)] - Done" | ||
} | ||
Write-Verbose 'Resolving dependencies - Done' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters