From 52c308e554625f655443624f3e47e7e58c5cf536 Mon Sep 17 00:00:00 2001 From: AdmiringWorm Date: Sat, 4 May 2024 19:28:10 +0200 Subject: [PATCH] (#310) Resolve windows binary only on windows --- Source/Cake.Codecov.Tests/CodecovRunnerFixture.cs | 9 +++++---- Source/Cake.Codecov/CodecovRunner.cs | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Source/Cake.Codecov.Tests/CodecovRunnerFixture.cs b/Source/Cake.Codecov.Tests/CodecovRunnerFixture.cs index 17ae0ff..8b9130b 100644 --- a/Source/Cake.Codecov.Tests/CodecovRunnerFixture.cs +++ b/Source/Cake.Codecov.Tests/CodecovRunnerFixture.cs @@ -1,3 +1,4 @@ +using System.Runtime.InteropServices; using Cake.Codecov.Internals; using Cake.Testing.Fixtures; @@ -8,7 +9,7 @@ internal class CodecovRunnerFixture : ToolFixture private readonly IPlatformDetector _platformDetector; public CodecovRunnerFixture() - : base("codecov.exe") + : base(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "codecov.exe" : "codecov") { } @@ -20,9 +21,9 @@ public CodecovRunnerFixture(IPlatformDetector platformDetector, string expectedE protected override void RunTool() { - var tool = _platformDetector != null ? - new CodecovRunner(_platformDetector, FileSystem, Environment, ProcessRunner, Tools) : - new CodecovRunner(FileSystem, Environment, ProcessRunner, Tools); + var tool = _platformDetector != null + ? new CodecovRunner(_platformDetector, FileSystem, Environment, ProcessRunner, Tools) + : new CodecovRunner(FileSystem, Environment, ProcessRunner, Tools); tool.Run(Settings); } } diff --git a/Source/Cake.Codecov/CodecovRunner.cs b/Source/Cake.Codecov/CodecovRunner.cs index b35cfa9..d024b63 100644 --- a/Source/Cake.Codecov/CodecovRunner.cs +++ b/Source/Cake.Codecov/CodecovRunner.cs @@ -55,10 +55,11 @@ protected override IEnumerable GetToolExecutableNames() } else { - // Just to make sonarlint happy :) + // The official version of Codecov CLI can not run with the exe + // on anything other than Windows. As such we only return this + // in the else statement. + yield return "codecov.exe"; } - - yield return "codecov.exe"; } protected override string GetToolName() => "Codecov";