Skip to content

Commit 2272358

Browse files
committed
(GH-512) Display exit code for packages
If a package is a warning or an error, display that exit code result next to the package name.
1 parent 0e9b775 commit 2272358

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
372372
this.Log().Warn(ChocolateyLoggers.Important, "Warnings:");
373373
foreach (var warning in packageInstalls.Where(p => p.Value.Warning).or_empty_list_if_null())
374374
{
375-
this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name));
375+
this.Log().Warn(ChocolateyLoggers.Important, " - {0}{1}".format_with(warning.Value.Name, warning.Value.ExitCode != 0 ? " (exit code {0})".format_with(warning.Value.ExitCode) : string.Empty));
376376
}
377377
}
378378

@@ -381,7 +381,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
381381
this.Log().Error("Failures:");
382382
foreach (var failure in packageInstalls.Where(p => !p.Value.Success).or_empty_list_if_null())
383383
{
384-
this.Log().Error(" - {0}".format_with(failure.Value.Name));
384+
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
385385
}
386386
}
387387

@@ -574,7 +574,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
574574
this.Log().Warn(ChocolateyLoggers.Important, "Warnings:");
575575
foreach (var warning in packageUpgrades.Where(p => p.Value.Warning).or_empty_list_if_null())
576576
{
577-
this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name));
577+
this.Log().Warn(ChocolateyLoggers.Important, " - {0}{1}".format_with(warning.Value.Name, warning.Value.ExitCode != 0 ? " (exit code {0})".format_with(warning.Value.ExitCode) : string.Empty));
578578
}
579579
}
580580

@@ -583,7 +583,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
583583
this.Log().Error("Failures:");
584584
foreach (var failure in packageUpgrades.Where(p => !p.Value.Success).or_empty_list_if_null())
585585
{
586-
this.Log().Error(" - {0}".format_with(failure.Value.Name));
586+
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
587587
}
588588
}
589589

@@ -654,7 +654,7 @@ public ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
654654
this.Log().Error("Failures");
655655
foreach (var failure in packageUninstalls.Where(p => !p.Value.Success).or_empty_list_if_null())
656656
{
657-
this.Log().Error(" - {0}".format_with(failure.Value.Name));
657+
this.Log().Error(" - {0}{1}".format_with(failure.Value.Name, failure.Value.ExitCode != 0 ? " (exit code {0})".format_with(failure.Value.ExitCode) : string.Empty));
658658
}
659659
}
660660

src/chocolatey/infrastructure/results/PackageResult.cs

+1
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public bool Warning
4141
public string InstallLocation { get; set; }
4242
public string Source { get; set; }
4343
public string SourceUri { get; set; }
44+
public int ExitCode { get; set; }
4445

4546
public PackageResult(IPackage package, string installLocation, string source = null) : this(package.Id.to_lower(), package.Version.to_string(), installLocation)
4647
{

0 commit comments

Comments
 (0)