Skip to content

Commit

Permalink
Remove duplicated tables when printing references (#19)
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Chavakis <[email protected]>
  • Loading branch information
mersadk and tomchavakis authored Mar 29, 2020
1 parent ed865b8 commit 60be9f3
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions src/Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,12 @@ public async Task<bool> PrintReferencesAsync(string projectPath, bool uniqueList
foreach (var item in projects)
{
IEnumerable<string> references = this.GetProjectReferences(item);
var currentProjectLicenses = await this.GetNugetInformationAsync(item, references);
licenses.Add(currentProjectLicenses);

if (uniqueList)
if (!uniqueList)
{
licenses.Add(await this.GetNugetInformationAsync(item, references));
}
else
{
licenses.Add(await this.GetNugetInformationAsync(item, references));
PrintLicenses(licenses);
PrintLicenses(currentProjectLicenses);
}

result = true;
Expand All @@ -182,18 +179,14 @@ public async Task<bool> PrintReferencesAsync(string projectPath, bool uniqueList
return result;
}

public void PrintLicenses(List<Dictionary<string, Package>> licenses)
public void PrintLicenses(Dictionary<string, Package> licenses)
{
if (licenses.Any())
{
Console.WriteLine(Environment.NewLine + "References:");

foreach (var license in licenses)
{
Console.WriteLine(license.ToStringTable(new[] { "Reference", "Licence", "Version", "LicenceType" },
a => a.Value.Metadata.Id ?? "---", a => a.Value.Metadata.LicenseUrl ?? "---",
a => a.Value.Metadata.Version ?? "---", a => (a.Value.Metadata.License != null ? a.Value.Metadata.License.Text : "---")));
}
Console.WriteLine(licenses.ToStringTable(new[] { "Reference", "Licence", "Version", "LicenceType" },
a => a.Value.Metadata.Id ?? "---", a => a.Value.Metadata.LicenseUrl ?? "---",
a => a.Value.Metadata.Version ?? "---", a => (a.Value.Metadata.License != null ? a.Value.Metadata.License.Text : "---")));
}
}

Expand Down

0 comments on commit 60be9f3

Please sign in to comment.