@@ -14,11 +14,11 @@ public enum LocalState { Idle, Connecting, Connected, Error, Disconnected };
1414
1515 public class BrowserStackTunnel : IDisposable
1616 {
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 ( ) ?
2222 Environment . GetFolderPath ( Environment . SpecialFolder . Personal ) :
2323 Environment . ExpandEnvironmentVariables ( "%HOMEDRIVE%%HOMEPATH%" ) ;
2424 public static readonly string [ ] basePaths = new string [ ] {
@@ -37,10 +37,51 @@ public class BrowserStackTunnel : IDisposable
3737
3838 Process process = null ;
3939
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 ( )
4157 {
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" ;
4485 }
4586
4687 public virtual void addBinaryPath ( string binaryAbsolute )
@@ -79,7 +120,7 @@ public virtual void fallbackPaths()
79120
80121 public void modifyBinaryPermission ( )
81122 {
82- if ( isDarwin ( ) )
123+ if ( ! IsWindows ( ) )
83124 {
84125 try
85126 {
0 commit comments