Skip to content

Commit

Permalink
nuget package management bugfixing
Browse files Browse the repository at this point in the history
  • Loading branch information
fernandoescolar committed Nov 25, 2024
1 parent 057caba commit d570875
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/extensions/nuget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,22 @@ export async function getNugetFeeds(projectPath: string): Promise<NugetFeed[]> {
}
}

if (result.findIndex(f => f.name === name) < 0) {
const existing = result.find(f => f.name === name);
if (!existing) {
const feed: NugetFeed = { name, url, searchApiUrl: '', packageVersionsUrl: '', userName, password };
result.push(feed);
} else {
if (!existing.url) {
existing.url = url;
existing.searchApiUrl = '';
existing.packageVersionsUrl = '';
}
if (!existing.userName) {
existing.userName = userName;
}
if (!existing.password) {
existing.password = password;
}
}
}
}
Expand Down Expand Up @@ -183,7 +196,7 @@ function getFetchOptions(feed: NugetFeed): RequestInit {

export async function searchPackagesByName(projectPath: string, query: string): Promise<NugetPackage[]> {
const feeds = await getNugetFeeds(projectPath);
const promises = feeds.map(feed => searchNugetPackage(feed, query));
const promises = feeds.map(feed => searchNugetPackage(feed, query).then(packages => packages).catch(() => []));
const results = await Promise.all(promises);
const packages = results.flatMap(result => result);
return packages.reduce((acc, pkg) => {
Expand All @@ -200,7 +213,7 @@ export async function searchPackageVersions(projectPath: string, id: string, inc
uniqueVersions = versionsCache[id].versions;
} else {
const feeds = await getNugetFeeds(projectPath);
const promises = feeds.map(feed => getNugetPackageVersions(feed, id));
const promises = feeds.map(feed => getNugetPackageVersions(feed, id).then(versions => versions).catch(() => []));
const results = await Promise.all(promises);
const versions = results.flatMap(result => result);
uniqueVersions = Array.from(new Set(versions));
Expand Down

0 comments on commit d570875

Please sign in to comment.