Skip to content

Commit

Permalink
Fix missing version folder (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasNieto authored Sep 21, 2024
1 parent 3486fd8 commit 1563df4
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/AnyPackage.Pkgx.psm1
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit 1563df4

Please sign in to comment.