From 9df6fd0ed3e05878332325f5a6b4b5f26613db7e Mon Sep 17 00:00:00 2001 From: Joel Bennett Date: Sun, 5 Apr 2015 01:58:16 -0400 Subject: [PATCH] (GH-223) Fix handling of LocalOnly for API Move test into the PackageService so it happens during execution regardless of how it's called. --- .../infrastructure.app/commands/ChocolateyListCommand.cs | 6 ------ .../services/ChocolateyPackageService.cs | 9 +++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs index 8d6c311480..0d805f1b56 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs @@ -68,12 +68,6 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati public void handle_additional_argument_parsing(IList unparsedArguments, ChocolateyConfiguration configuration) { configuration.Input = string.Join(" ", unparsedArguments); - - if (configuration.ListCommand.LocalOnly) - { - configuration.Sources = ApplicationParameters.PackagesLocation; - configuration.Prerelease = true; - } } public void handle_validation(ChocolateyConfiguration configuration) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 0199aad942..a457a11428 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -90,9 +90,14 @@ public IEnumerable list_run(ChocolateyConfiguration config) { var packages = new List(); + if (config.ListCommand.LocalOnly) + { + config.Sources = ApplicationParameters.PackagesLocation; + config.Prerelease = true; + } foreach (var package in _nugetService.list_run(config)) { - if (!config.ListCommand.LocalOnly && !config.ListCommand.IncludeRegistryPrograms) + if (!config.ListCommand.LocalOnly || !config.ListCommand.IncludeRegistryPrograms) { yield return package; } @@ -489,7 +494,7 @@ public ConcurrentDictionary uninstall_run(ChocolateyConfi this.Log().Info(@"Uninstalling the following packages:"); this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(config.PackageNames)); - foreach (var packageConfigFile in config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Where(p => p.EndsWith(".config")).ToList()) + if (config.PackageNames.Split(new[] { ApplicationParameters.PackageNamesSeparator }, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Any(p => p.EndsWith(".config"))) { throw new ApplicationException("A packages.config file is only used with installs."); }