From 526f3c36045445d0f18bc5953833a7d88c9e21a6 Mon Sep 17 00:00:00 2001 From: Justin Grote Date: Sun, 8 Sep 2024 15:06:33 -0700 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8Allow=20Source=20to=20be=20specified?= =?UTF-8?q?=20just=20by=20hostname=20(e.g.=20pwsh.gallery)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ModuleFast.psm1 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/ModuleFast.psm1 b/ModuleFast.psm1 index af90d38..a5ee9c3 100644 --- a/ModuleFast.psm1 +++ b/ModuleFast.psm1 @@ -254,14 +254,18 @@ function Install-ModuleFast { ) begin { trap {$PSCmdlet.ThrowTerminatingError($PSItem)} - - - #Clear the ModuleFastCache if -Update is specified to ensure fresh lookups of remote module availability if ($Update) { Clear-ModuleFastCache } + #Cleanup that allows for shorthand such as pwsh.gallery + [Uri]$srcTest = $Source + if ($srcTest.Scheme -notin 'http', 'https') { + Write-Debug "Appending https and index.json to $Source" + $Source = "https://$Source/index.json" + } + $defaultRepoPath = $(Join-Path ([Environment]::GetFolderPath('LocalApplicationData')) 'powershell/Modules') if (-not $Destination) { #Special function that will retrieve the default module path for the current user @@ -279,6 +283,8 @@ function Install-ModuleFast { throw 'Failed to determine destination path. This is a bug, please report it, it should always have something by this point.' } + + # Require approval to create the destination folder if it is not our default path, otherwise this is automatic if (-not (Test-Path $Destination)) { if ($configRepoPath -or