Skip to content

Commit d49f5a4

Browse files
author
Amaury Levé
committed
Returns a different script based on OS
1 parent 18642f0 commit d49f5a4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

SonarScanner.Shim/SonarScanner.Wrapper.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
* along with this program; if not, write to the Free Software Foundation,
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
20-
21-
using SonarQube.Common;
20+
2221
using System;
2322
using System.Collections.Generic;
2423
using System.Diagnostics;
2524
using System.IO;
2625
using System.Linq;
26+
using SonarQube.Common;
2727

2828
namespace SonarScanner.Shim
2929
{
@@ -117,7 +117,16 @@ private static void InternalExecute(AnalysisConfig config, IEnumerable<string> u
117117
private static string FindScannerExe()
118118
{
119119
var binFolder = Path.GetDirectoryName(typeof(SonarScannerWrapper).Assembly.Location);
120-
return Path.Combine(binFolder, "sonar-scanner-" + SonarScannerVersion + @"\bin\sonar-scanner.bat");
120+
var scannerScript = IsWindowsOperatingSystem()
121+
? @"sonar-scanner.bat"
122+
: @"sonar-scanner.sh";
123+
return Path.Combine(binFolder, $"sonar-scanner-{SonarScannerVersion}", "bin", scannerScript);
124+
}
125+
126+
private static bool IsWindowsOperatingSystem()
127+
{
128+
return Environment.OSVersion.Platform != PlatformID.MacOSX &&
129+
Environment.OSVersion.Platform != PlatformID.Unix;
121130
}
122131

123132
public /* for test purposes */ static bool ExecuteJavaRunner(AnalysisConfig config, IEnumerable<string> userCmdLineArguments, ILogger logger, string exeFileName, string propertiesFileName)

0 commit comments

Comments
 (0)