Skip to content

Commit fdd10ea

Browse files
🩹 [Patch]: Add Retry on Install-Module (#39)
## Description This pull request includes changes to the `Resolve-PSModuleDependency.ps1` script to enhance its reliability by adding retry logic for module installations. Enhancements to module installation reliability: * [`scripts/helpers/Resolve-PSModuleDependency.ps1`](diffhunk://#diff-48557b471e7d62a89be3627235334ab8a39eb6119174abb61714b92d844508e2L1-R3): Added a `#Requires` statement to ensure the `Retry` module is available. * [`scripts/helpers/Resolve-PSModuleDependency.ps1`](diffhunk://#diff-48557b471e7d62a89be3627235334ab8a39eb6119174abb61714b92d844508e2R52-R54): Wrapped the `Install-Module` command with a `Retry` block to attempt installation up to 5 times with a 10-second delay between attempts. ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent ca12dbb commit fdd10ea

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

scripts/helpers/Resolve-PSModuleDependency.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function Resolve-PSModuleDependency {
1+
#Requires -Modules Retry
2+
3+
function Resolve-PSModuleDependency {
24
<#
35
.SYNOPSIS
46
Resolve dependencies for a module based on the manifest file.
@@ -47,7 +49,9 @@
4749
Write-Verbose "[$($installParams.Name)] - Installing module"
4850
$VerbosePreferenceOriginal = $VerbosePreference
4951
$VerbosePreference = 'SilentlyContinue'
50-
Install-Module @installParams -AllowPrerelease:$false
52+
Retry -Count 5 -Delay 10 {
53+
Install-Module @installParams -AllowPrerelease:$false
54+
}
5155
$VerbosePreference = $VerbosePreferenceOriginal
5256
Write-Verbose "[$($installParams.Name)] - Importing module"
5357
$VerbosePreferenceOriginal = $VerbosePreference

0 commit comments

Comments
 (0)