@@ -4,15 +4,15 @@ var Log = require('./logger'),
44 fs = require ( 'fs' ) ,
55 http = require ( 'http' ) ,
66 windows = ( ( process . platform . match ( / w i n 3 2 / ) || process . platform . match ( / w i n 6 4 / ) ) !== null ) ,
7- localBinary = __dirname + ( windows ? '/BrowserStackTunnel.jar ' : '/BrowserStackLocal' ) ,
7+ localBinary = __dirname + ( windows ? '/BrowserStackTunnel.exe ' : '/BrowserStackLocal' ) ,
88 utils = require ( './utils' ) ,
99 config = require ( './config' ) ;
1010
1111var Tunnel = function Tunnel ( key , port , uniqueIdentifier , callback , err ) {
1212 var that = { } ;
1313
1414 function tunnelLauncher ( ) {
15- var tunnelCommand = ( windows ? 'java -jar ' : '' ) + localBinary + ' ' ;
15+ var tunnelCommand = localBinary + ' ' ;
1616 if ( config . debug ) tunnelCommand += ' -v ' ;
1717 tunnelCommand += key + ' ' ;
1818 tunnelCommand += 'localhost' + ',' ;
@@ -63,6 +63,16 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
6363 that . process = subProcess ;
6464 }
6565
66+ function getBinaryAddress ( ) {
67+ binaryURL = "http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal" ;
68+ if ( windows ) {
69+ binaryURL += ".exe" ;
70+ } else {
71+ binaryURL += "-" + process . platform + "-" + process . arch ;
72+ }
73+ return binaryURL ;
74+ }
75+
6676 function checkAndAddProxy ( ) {
6777 var proxy = config . proxy ;
6878 if ( typeof proxy == 'undefined' ) {
@@ -83,14 +93,13 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
8393 tunnelLauncher ( ) ;
8494 return ;
8595 }
86- logger . debug ( 'Downloading BrowserStack Local to `%s`' , localBinary ) ;
96+ logger . debug ( 'Downloading BrowserStack Local to `%s` from `%s` ' , localBinary , getBinaryAddress ( ) ) ;
8797
8898 var file = fs . createWriteStream ( localBinary ) ;
8999 var request = http . get (
90- ( windows ? "http://www.browserstack.com/BrowserStackTunnel.jar" : ( "http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process . platform + "-" + process . arch ) ) ,
100+ getBinaryAddress ( ) ,
91101 function ( response ) {
92102 response . pipe ( file ) ;
93-
94103 response . on ( 'end' , function ( ) {
95104 fs . chmodSync ( localBinary , 0700 ) ;
96105 setTimeout ( function ( ) {
@@ -106,4 +115,4 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) {
106115 return that ;
107116} ;
108117
109- exports . Tunnel = Tunnel ;
118+ exports . Tunnel = Tunnel ;
0 commit comments