Skip to content

Commit

Permalink
Refactor GetPackage
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasNieto committed Dec 10, 2024
1 parent 9a31bb9 commit 75876ad
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/code/MsiProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ public void FindPackage(PackageRequest request)
}

public void GetPackage(PackageRequest request)
{
foreach (var package in GetPackageImpl(request))
{
request.WritePackage(package);
}
}

private IEnumerable<PackageInfo> GetPackageImpl(PackageRequest request)
{
using var powershell = PowerShell.Create(RunspaceMode.CurrentRunspace);
powershell.AddCommand("Get-Package")
Expand Down Expand Up @@ -62,15 +70,13 @@ public void GetPackage(PackageRequest request)
source = null;
}

var package = new PackageInfo(result.Name,
yield return new PackageInfo(result.Name,
result.Version,
source,
result.Description,
dependencies: null,
result.Metadata.ToDictionary(x => x.Key, x => x.Value),
ProviderInfo);

request.WritePackage(package);
}
}

Expand Down

0 comments on commit 75876ad

Please sign in to comment.