Skip to content

Commit

Permalink
(GH-1134) use console adapter for width
Browse files Browse the repository at this point in the history
When output is being redirected, we need to ensure we do not get "The
handle is invalid" message.
  • Loading branch information
ferventcoder committed Mar 3, 2017
1 parent 0686c65 commit eaaf5a1
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/chocolatey/infrastructure.app/nuget/NugetCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,35 @@ namespace chocolatey.infrastructure.app.nuget
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Text;
using adapters;
using infrastructure.configuration;
using NuGet;
using configuration;
using logging;
using Console = adapters.Console;
using Environment = adapters.Environment;

// ReSharper disable InconsistentNaming

public sealed class NugetCommon
{
private static Lazy<IConsole> _console = new Lazy<IConsole>(() => new Console());

[EditorBrowsable(EditorBrowsableState.Never)]
public static void initialize_with(Lazy<IConsole> console)
{
_console = console;
}

private static IConsole Console
{
get { return _console.Value; }
}

public static IFileSystem GetNuGetFileSystem(ChocolateyConfiguration configuration, ILogger nugetLogger)
{
return new ChocolateyPhysicalFileSystem(ApplicationParameters.PackagesLocation) { Logger = nugetLogger };
Expand Down Expand Up @@ -113,7 +130,7 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con
}
catch (Exception ex)
{
"chocolatey".Log().Warn("Attempted to use a source name {0} to get default source but failed:{1} {2}".format_with(sourceValue, Environment.NewLine, ex.Message));
"chocolatey".Log().Warn("Attempted to use a source name {0} to get default source but failed:{1} {2}".format_with(sourceValue, System.Environment.NewLine, ex.Message));
}
}

Expand Down Expand Up @@ -174,7 +191,7 @@ public static IPackageManager GetPackageManager(ChocolateyConfiguration configur
{
var pkg = e.Package;
"chocolatey".Log().Info(ChocolateyLoggers.Important, "{0}{1} v{2}{3}{4}{5}".format_with(
Environment.NewLine,
System.Environment.NewLine,
pkg.Id,
pkg.Version.to_string(),
configuration.Force ? " (forced)" : string.Empty,
Expand Down

0 comments on commit eaaf5a1

Please sign in to comment.