@@ -14,11 +14,11 @@ public enum LocalState { Idle, Connecting, Connected, Error, Disconnected };
14
14
15
15
public class BrowserStackTunnel : IDisposable
16
16
{
17
- static readonly string binaryName = isDarwin ( ) ? "BrowserStackLocal-darwin-x64" : "BrowserStackLocal.exe" ;
18
- static readonly string downloadURL = isDarwin ( ) ?
19
- "https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal-darwin-x64" :
20
- "https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal.exe" ;
21
- static readonly string homepath = isDarwin ( ) ?
17
+ static readonly string uname = Util . GetUName ( ) ;
18
+ static readonly string binaryName = GetBinaryName ( ) ;
19
+ static readonly string downloadURL = "https://www.browserstack.com/local-testing/downloads/binaries/" + binaryName ;
20
+
21
+ static readonly string homepath = ! IsWindows ( ) ?
22
22
Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) :
23
23
Environment . ExpandEnvironmentVariables ( "%HOMEDRIVE%%HOMEPATH%" ) ;
24
24
public static readonly string [ ] basePaths = new string [ ] {
@@ -37,10 +37,51 @@ public class BrowserStackTunnel : IDisposable
37
37
38
38
Process process = null ;
39
39
40
- static Boolean isDarwin ( )
40
+ static bool IsDarwin ( string osName )
41
+ {
42
+ return osName . Contains ( "darwin" ) ;
43
+ }
44
+
45
+
46
+ static bool IsWindows ( )
47
+ {
48
+ return Environment . OSVersion . VersionString ? . ToLower ( ) . Contains ( "windows" ) ?? false ;
49
+ }
50
+
51
+ static bool IsLinux ( string osName )
52
+ {
53
+ return osName . Contains ( "linux" ) ;
54
+ }
55
+
56
+ static bool IsAlpine ( )
41
57
{
42
- OperatingSystem os = Environment . OSVersion ;
43
- return os . Platform . ToString ( ) == "Unix" ;
58
+ try
59
+ {
60
+ string [ ] output = Util . RunShellCommand ( "grep" , "-w \' NAME\' /etc/os-release" ) ;
61
+ return output [ 0 ] ? . ToLower ( ) ? . Contains ( "alpine" ) ?? false ;
62
+ }
63
+ catch ( System . Exception ex )
64
+ {
65
+ Console . WriteLine ( "Exception while check isAlpine " + ex ) ;
66
+ }
67
+ return false ;
68
+ }
69
+
70
+ static string GetBinaryName ( )
71
+ {
72
+ if ( IsWindows ( ) ) return "BrowserStackLocal.exe" ;
73
+ if ( IsDarwin ( uname ) ) return "BrowserStackLocal-darwin-x64" ;
74
+
75
+ if ( IsLinux ( uname ) )
76
+ {
77
+ if ( Util . Is64BitOS ( ) )
78
+ {
79
+ return IsAlpine ( ) ? "BrowserStackLocal-alpine" : "BrowserStackLocal-linux-x64" ;
80
+ }
81
+ return "BrowserStackLocal-linux-ia32" ;
82
+ }
83
+
84
+ return "BrowserStackLocal.exe" ;
44
85
}
45
86
46
87
public virtual void addBinaryPath ( string binaryAbsolute )
@@ -79,7 +120,7 @@ public virtual void fallbackPaths()
79
120
80
121
public void modifyBinaryPermission ( )
81
122
{
82
- if ( isDarwin ( ) )
123
+ if ( ! IsWindows ( ) )
83
124
{
84
125
try
85
126
{
0 commit comments