-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rever vsts-prequisites to not call a specific version of pester.
- Loading branch information
1 parent
f16ef42
commit 791b1da
Showing
1 changed file
with
17 additions
and
27 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 |
---|---|---|
@@ -1,40 +1,30 @@ | ||
param ( | ||
#vsts-prequisites.ps1 | ||
|
||
param ( | ||
[string] | ||
$Repository = 'PSGallery' | ||
) | ||
|
||
$modules = @( | ||
@{ Name = "Pester"; Version = "5.6.1" }, | ||
"PSFramework", | ||
"PSModuleDevelopment" | ||
) | ||
$modules = @("Pester", "PSFramework", "PSModuleDevelopment") | ||
|
||
# Automatically add missing dependencies | ||
# TODO: uncomment this block of code below and fix RobustCloudCommand error. | ||
|
||
# Load required modules from Hawk.psd1 | ||
$data = Import-PowerShellDataFile -Path "$PSScriptRoot\..\Hawk\Hawk.psd1" | ||
foreach ($dependency in $data.RequiredModules) { | ||
# Handle string dependencies | ||
if ($dependency -is [string]) { | ||
if (-not ($modules -contains $dependency)) { | ||
$modules += @{ Name = $dependency; Version = "" } | ||
} | ||
if ($modules -contains $dependency) { continue } | ||
$modules += $dependency | ||
} | ||
# Handle hashtable dependencies | ||
elseif ($dependency -is [hashtable]) { | ||
if (-not ($modules -contains $dependency.ModuleName)) { | ||
$modules += @{ Name = $dependency.ModuleName; Version = $dependency.RequiredVersion } | ||
} | ||
else { | ||
if ($modules -contains $dependency.ModuleName) { continue } | ||
$modules += $dependency.ModuleName | ||
} | ||
} | ||
|
||
# Install and import modules | ||
foreach ($module in $modules) { | ||
try { | ||
$moduleName = $module.Name | ||
$moduleVersion = $module.Version | ||
Write-Output "Installing $moduleName" | ||
Install-Module -Name $moduleName -RequiredVersion $moduleVersion -Force -SkipPublisherCheck -Repository $Repository | ||
Import-Module -Name $moduleName -Force -PassThru | ||
} catch { | ||
Write-Error "Failed to install or import module: $($module.Name). Error: $_" | ||
} | ||
} | ||
# Write-Output "Installing module: $module" | ||
Write-Output "Installing $module" | ||
Install-Module $module -Force -SkipPublisherCheck -Repository $Repository | ||
Import-Module $module -Force -PassThru | ||
} |