diff --git a/lib/local.js b/lib/local.js index 9b08830..d49b4bc 100644 --- a/lib/local.js +++ b/lib/local.js @@ -4,7 +4,7 @@ var Log = require('./logger'), fs = require('fs'), http = require('http'), windows = ((process.platform.match(/win32/) || process.platform.match(/win64/)) !== null), - localBinary = __dirname + (windows ? '/BrowserStackTunnel.jar' : '/BrowserStackLocal'), + localBinary = __dirname + (windows ? '/BrowserStackTunnel.exe' : '/BrowserStackLocal'), utils = require('./utils'), config = require('./config'); @@ -12,7 +12,7 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) { var that = {}; function tunnelLauncher() { - var tunnelCommand = (windows ? 'java -jar ' : '') + localBinary + ' '; + var tunnelCommand = localBinary + ' '; if (config.debug) tunnelCommand += ' -v '; tunnelCommand += key + ' '; tunnelCommand += 'localhost' + ','; @@ -63,6 +63,16 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) { that.process = subProcess; } + function getBinaryAddress() { + binaryURL = "http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal"; + if(windows) { + binaryURL += ".exe"; + } else { + binaryURL += "-" + process.platform + "-" + process.arch; + } + return binaryURL; + } + function checkAndAddProxy() { var proxy = config.proxy; if(typeof proxy == 'undefined') { @@ -83,14 +93,13 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) { tunnelLauncher(); return; } - logger.debug('Downloading BrowserStack Local to `%s`', localBinary); + logger.debug('Downloading BrowserStack Local to `%s` from `%s`', localBinary, getBinaryAddress()); var file = fs.createWriteStream(localBinary); var request = http.get( - (windows ? "http://www.browserstack.com/BrowserStackTunnel.jar" : ("http://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-" + process.platform + "-" + process.arch)), + getBinaryAddress(), function(response) { response.pipe(file); - response.on('end', function() { fs.chmodSync(localBinary, 0700); setTimeout(function() { @@ -106,4 +115,4 @@ var Tunnel = function Tunnel(key, port, uniqueIdentifier, callback, err) { return that; }; -exports.Tunnel = Tunnel; +exports.Tunnel = Tunnel; \ No newline at end of file