From fc9f008581276b17990eb51459da253043106ebb Mon Sep 17 00:00:00 2001 From: Thomas Nieto <38873752+ThomasNieto@users.noreply.github.com> Date: Sat, 21 Sep 2024 13:11:31 -0500 Subject: [PATCH] Fix missing version folder --- src/AnyPackage.Pkgx.psm1 | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/AnyPackage.Pkgx.psm1 b/src/AnyPackage.Pkgx.psm1 index 5235af6..db40591 100644 --- a/src/AnyPackage.Pkgx.psm1 +++ b/src/AnyPackage.Pkgx.psm1 @@ -1,4 +1,4 @@ -# Copyright (c) Thomas Nieto - All Rights Reserved +# Copyright (c) Thomas Nieto - All Rights Reserved # You may use, distribute and modify this code under the # terms of the MIT license. @@ -37,21 +37,27 @@ class PkgxProvider : PackageProvider, IFindPackage, IGetPackage, IInstallPackage $versionPath = Join-Path -Path $basePath -ChildPath "$name/v$versionBin" } else { $versionPath = Join-Path -Path $basePath -ChildPath "$name/v*" + $versionBin = $null } - $versionDirectory = Get-Item -LiteralPath $versionPath + $versionDirectory = Get-Item -LiteralPath $versionPath -ErrorAction SilentlyContinue - if ($versionDirectory.Target) { - $resolvedVersion = $versionDirectory.Target + if (-not $versionDirectory -and $versionBin) { + $version = $versionBin + } elseif (-not $versionDirectory) { + $version = $null + } elseif ($versionDirectory.Target) { + $version = $versionDirectory.Target -replace 'v', '' } else { - $resolvedVersion = $versionDirectory.Name + $version = $versionDirectory.Name -replace 'v', '' } - $version = $resolvedVersion -replace 'v', '' - - if ($request.IsMatch($name, $version)) { + if ($version -and $request.IsMatch($name, $version)) { $packageInfo = [PackageInfo]::new($name, $version, $request.ProviderInfo) $request.WritePackage($packageInfo) + } elseif ($request.IsMatch($name)) { + $packageInfo = [PackageInfo]::new($name, $request.ProviderInfo) + $request.WritePackage($packageInfo) } } }