Skip to content

Commit c03d87e

Browse files
committed
🐛 Fix up SpecFile
1 parent 89ebff5 commit c03d87e

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

ModuleFast.psm1

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ function Install-ModuleFast {
9191
if (-not $Destination) {
9292
$Destination = $defaultRepoPath
9393
} elseif ($IsWindows -and $Destination -eq 'CurrentUser') {
94-
$windowsDefaultDocumentsPath = Join-Path [environment]::GetFolderPath('MyDocuments') 'PowerShell/Modules'
94+
$windowsDefaultDocumentsPath = Join-Path ([Environment]::GetFolderPath('MyDocuments')) 'PowerShell/Modules'
9595
$Destination = $windowsDefaultDocumentsPath
9696
}
9797

@@ -132,7 +132,7 @@ function Install-ModuleFast {
132132

133133
$cancelSource = [CancellationTokenSource]::new()
134134

135-
[List[ModuleFastSpec]]$ModulesToInstall = @()
135+
[HashSet[ModuleFastSpec]]$ModulesToInstall = @()
136136
[List[ModuleFastInfo]]$installPlan = @()
137137
}
138138

@@ -142,7 +142,10 @@ function Install-ModuleFast {
142142
switch ($PSCmdlet.ParameterSetName) {
143143
'Specification' {
144144
foreach ($ModuleToInstall in $Specification) {
145-
$ModulesToInstall.Add($ModuleToInstall)
145+
$duplicate = $ModulesToInstall.Add($ModuleToInstall)
146+
if ($duplicate) {
147+
Write-Warning "$ModuleToInstall was specified twice, skipping duplicate"
148+
}
146149
}
147150
break
148151

@@ -162,14 +165,19 @@ function Install-ModuleFast {
162165
end {
163166
if (-not $installPlan) {
164167
if ($ModulesToInstall.Count -eq 0 -and $PSCmdlet.ParameterSetName -eq 'Specification') {
165-
Write-Verbose 'No modules specified to install. Beginning SpecFile detection...'
168+
Write-Verbose '🔎 No modules specified to install. Beginning SpecFile detection...'
166169
$modulesToInstall = if ($CI -and (Test-Path $CILockFilePath)) {
167170
Write-Debug "Found lockfile at $CILockFilePath. Using for specification evaluation and ignoring all others."
168171
ConvertFrom-RequiredSpec -RequiredSpecPath $CILockFilePath
169172
} else {
170-
$specFiles = Find-RequiredSpecFile $PWD -CILockFileHint $CILockFilePath
173+
$Destination = $PWD
174+
$specFiles = Find-RequiredSpecFile $Destination -CILockFileHint $CILockFilePath
175+
if (-not $specFiles) {
176+
Write-Warning "No specfiles found in $Destination. Please ensure you have a .requires.json or .requires.psd1 file in the current directory, specify a path with -Path, or define specifications with the -Specification parameter to skip this search."
177+
}
171178
foreach ($specfile in $specFiles) {
172-
ConvertFrom-RequiredSpec -RequiredSpecPath $Path
179+
Write-Verbose "Found Specfile $specFile. Evaluating..."
180+
ConvertFrom-RequiredSpec -RequiredSpecPath $specFile
173181
}
174182
}
175183
}
@@ -285,6 +293,10 @@ function New-ModuleFastClient {
285293
}
286294

287295
function Get-ModuleFastPlan {
296+
<#
297+
.NOTES
298+
THIS COMMAND IS DEPRECATED AND WILL NOT RECEIVE PARAMETER UPDATES. Please use Install-ModuleFast -Plan instead.
299+
#>
288300
[CmdletBinding()]
289301
[OutputType([ModuleFastInfo])]
290302
param(
@@ -343,7 +355,7 @@ function Get-ModuleFastPlan {
343355
Write-Verbose "${moduleSpec}: Evaluating Module Specification"
344356
[ModuleFastInfo]$localMatch = Find-LocalModule $moduleSpec -Update:$Update -BestCandidate:([ref]$bestLocalCandidate)
345357
if ($localMatch) {
346-
Write-Debug "${localMatch}: 🎯 FOUND satisfing version $($localMatch.ModuleVersion) at $($localMatch.Location). Skipping remote search."
358+
Write-Debug "${localMatch}: 🎯 FOUND satisfying version $($localMatch.ModuleVersion) at $($localMatch.Location). Skipping remote search."
347359
#TODO: Capture this somewhere that we can use it to report in the deploy plan
348360
continue
349361
}
@@ -1520,7 +1532,7 @@ filter ConvertFrom-RequiredSpec {
15201532
}
15211533

15221534
function Find-RequiredSpecFile ([string]$Path) {
1523-
Write-Debug "Attempting to find a Required Spec file at $Path"
1535+
Write-Debug "Attempting to find Required Specfile(s) at $Path"
15241536

15251537
$resolvedPath = Resolve-Path $Path
15261538

@@ -1533,6 +1545,7 @@ function Find-RequiredSpecFile ([string]$Path) {
15331545
if (-not $requireFiles) {
15341546
throw [NotSupportedException]"Could not find any required spec files in $Path. Verify the path is correct or specify Module Specifications either via -Path or -Specification"
15351547
}
1548+
return $requireFiles
15361549
}
15371550

15381551
function Read-RequiredSpecFile ($RequiredSpecPath) {

0 commit comments

Comments
 (0)