7
7
using System . Security . AccessControl ;
8
8
using System . Security . Principal ;
9
9
using Newtonsoft . Json . Linq ;
10
- using System . Runtime . InteropServices ;
11
10
12
11
namespace BrowserStack
13
12
{
14
13
public enum LocalState { Idle , Connecting , Connected , Error , Disconnected } ;
15
14
16
15
public class BrowserStackTunnel : IDisposable
17
16
{
18
- static string binaryName = GetBinaryName ( ) ;
17
+ static readonly string uname = Util . GetUName ( ) ;
18
+ static readonly string binaryName = GetBinaryName ( ) ;
19
19
static readonly string downloadURL = "https://www.browserstack.com/local-testing/downloads/binaries/" + binaryName ;
20
- static readonly string homepath = IsDarwin ( ) || IsLinux ( ) ?
20
+
21
+ static readonly string homepath = ! IsWindows ( ) ?
21
22
Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) :
22
23
Environment . ExpandEnvironmentVariables ( "%HOMEDRIVE%%HOMEPATH%" ) ;
23
24
public static readonly string [ ] basePaths = new string [ ] {
@@ -36,9 +37,9 @@ public class BrowserStackTunnel : IDisposable
36
37
37
38
Process process = null ;
38
39
39
- static bool IsDarwin ( )
40
+ static bool IsDarwin ( string osName )
40
41
{
41
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
42
+ if ( osName . Contains ( "darwin" ) )
42
43
{
43
44
return true ;
44
45
}
@@ -48,16 +49,16 @@ static bool IsDarwin()
48
49
49
50
static bool IsWindows ( )
50
51
{
51
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
52
+ if ( Environment . OSVersion . VersionString ? . ToLower ( ) . Contains ( "windows" ) ?? false )
52
53
{
53
54
return true ;
54
55
}
55
56
return false ;
56
57
}
57
58
58
- static bool IsLinux ( )
59
+ static bool IsLinux ( string osName )
59
60
{
60
- if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
61
+ if ( osName . Contains ( "linux" ) )
61
62
{
62
63
return true ;
63
64
}
@@ -69,7 +70,7 @@ static bool IsAlpine()
69
70
try
70
71
{
71
72
string [ ] output = Util . RunShellCommand ( "grep -w 'NAME' /etc/os-release" ) ;
72
- if ( string . IsNullOrEmpty ( output [ 0 ] ) && output [ 0 ] . Contains ( "Alpine" ) )
73
+ if ( output [ 0 ] ? . ToLower ( ) ? . Contains ( "alpine" ) ?? false )
73
74
{
74
75
return true ;
75
76
}
@@ -83,17 +84,17 @@ static bool IsAlpine()
83
84
84
85
static string GetBinaryName ( )
85
86
{
86
- if ( IsDarwin ( ) )
87
+ if ( IsWindows ( ) )
87
88
{
88
- return "BrowserStackLocal-darwin-x64 " ;
89
+ return "BrowserStackLocal.exe " ;
89
90
}
90
- else if ( IsWindows ( ) )
91
+ else if ( IsDarwin ( uname ) )
91
92
{
92
- return "BrowserStackLocal.exe " ;
93
+ return "BrowserStackLocal-darwin-x64 " ;
93
94
}
94
- else if ( IsLinux ( ) )
95
+ else if ( IsLinux ( uname ) )
95
96
{
96
- if ( Environment . Is64BitOperatingSystem )
97
+ if ( Util . Is64BitOS ( ) )
97
98
{
98
99
if ( IsAlpine ( ) )
99
100
{
@@ -148,7 +149,7 @@ public virtual void fallbackPaths()
148
149
149
150
public void modifyBinaryPermission ( )
150
151
{
151
- if ( IsDarwin ( ) || IsLinux ( ) )
152
+ if ( ! IsWindows ( ) )
152
153
{
153
154
try
154
155
{
0 commit comments