Skip to content

Commit 5df24bf

Browse files
🩹 [Patch]: Add Retry on Install-Module (#85)
## Description This pull request includes several changes to the `scripts/helpers/Build/Resolve-PSModuleDependency.ps1` and `scripts/main.ps1` files to improve module dependency resolution and error handling. ### Improvements to module dependency resolution and error handling: * [`scripts/helpers/Build/Resolve-PSModuleDependency.ps1`](diffhunk://#diff-b278dc96f784d462b15a4fe67b088a5b5d9cc502dd6eba3d660da085e576652fL1-R3): Added a requirement for the `Retry` module to handle retries during module installation. * [`scripts/helpers/Build/Resolve-PSModuleDependency.ps1`](diffhunk://#diff-b278dc96f784d462b15a4fe67b088a5b5d9cc502dd6eba3d660da085e576652fR52-R54): Implemented retry logic with 5 retries and a 10-second delay for the `Install-Module` command to improve robustness against transient errors. ### Minor formatting changes: * [`scripts/main.ps1`](diffhunk://#diff-dc2e5a659836b1b73abb03421c567f5018c2755677c4a0aa764cb26117b68011L1-R1): Fixed the casing of the `#Requires` directive for the `Utilities` module. ## 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 48fbb00 commit 5df24bf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

scripts/helpers/Build/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

scripts/main.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#REQUIRES -Modules Utilities
1+
#Requires -Modules Utilities
22

33
[CmdletBinding()]
44
param()

0 commit comments

Comments
 (0)