Skip to content

Commit

Permalink
Fix dependency parsing (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasNieto authored Mar 15, 2023
1 parent 10af9eb commit 97fe829
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/AnyPackage.PowerShellGet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
Copyright = '(c) 2023 Thomas Nieto. All rights reserved.'
Description = 'PowerShellGet provider for AnyPackage.'
PowerShellVersion = '5.1'
RequiredModules = @('AnyPackage', 'PowerShellGet')
RequiredModules = @(
@{ ModuleName = 'AnyPackage'; ModuleVersion = '0.4.1' },
'PowerShellGet')
FunctionsToExport = @()
CmdletsToExport = @()
AliasesToExport = @()
Expand Down
10 changes: 8 additions & 2 deletions src/AnyPackage.PowerShellGet.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,8 @@ function Write-Package {

$deps = [List[PackageDependency]]::new()
foreach ($dep in $resource.Dependencies) {
$dependency = [PackageDependency]::new($dep.Name, $dep.VersionRange)
$versionRange = [PackageVersionRange]::new($dep.VersionRange, $true)
$dependency = [PackageDependency]::new($dep.Name, $versionRange)
$deps.Add($dependency)
}

Expand All @@ -535,7 +536,12 @@ function Write-Package {
$version = $resource.Version.ToString()

if ($resource.Prerelease) {
$version = $version + '-' + $resource.Prerelease
# Version property is incorrect for 2 and 3 digits
# https://github.com/PowerShell/PowerShellGet/issues/697
$version = "{0}.{1}.{2}-{3}" -f $resource.Version.Major,
$resource.Version.Minor,
$resource.Version.Build,
$resource.Prerelease
}

$request.WritePackage($resource.Name, $version, $resource.Description, $source, $ht, $deps)
Expand Down
2 changes: 1 addition & 1 deletion test/Find-Package.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Describe Find-Package {
Context 'with -Version parameter' {
It 'should return value' {
$package = Find-PSResource -Name AnyPackage
Find-Package -Name AnyPackage -Version $package.Version |
Find-Package -Name AnyPackage -Version $package.Version.ToString() |
Should -Not -BeNullOrEmpty
}

Expand Down

0 comments on commit 97fe829

Please sign in to comment.