Skip to content

Commit

Permalink
(GH-1724) search - exit 1 on no results
Browse files Browse the repository at this point in the history
Instead of exiting with 0 if no results are found, exit with something
different to indicate that nothing was found. 0 would indicate a
success that there was results, where 1 would indicate something isn't
quite right if there was an expectation of finding something.
  • Loading branch information
ferventcoder committed Mar 11, 2019
1 parent 7f15fb0 commit 47cbdd8
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

namespace chocolatey.infrastructure.app.commands
{
using System;
using System.Collections.Generic;
using System.Linq;
using attributes;
Expand Down Expand Up @@ -201,7 +202,13 @@ public virtual void run(ChocolateyConfiguration configuration)
{
_packageService.ensure_source_app_installed(configuration);
// note: you must leave the .ToList() here or else the method won't be evaluated!
_packageService.list_run(configuration).ToList();
var packageResults = _packageService.list_run(configuration).ToList();

// if there are no results, exit with a 1.
if (packageResults.Count == 0)
{
Environment.ExitCode = 1;
}
}

public virtual IEnumerable<PackageResult> list(ChocolateyConfiguration configuration)
Expand Down

0 comments on commit 47cbdd8

Please sign in to comment.